0

I'm learning the basics of java for a few weeks and it's all fun! Did many micro-apps with it and overall, having a good time.

But while I was writing some code for my course, i was stuck at one part.

The app is about search bars using functions and arrays

  const Characters = [{name: 'Mickey Mouse', age: 93},{name: 'Winnie The Pooh', age: 96},{name: 'Donald Duck', age: 86},{name: 'Scrooge McDuck', age: 75}]

const searcbar = function(Charac, name){
    const searchalt = Charac.find(function(Naame, index){
        return Naame.name.toLowerCase() === name.toLowerCase()
    })
    return  searchalt
}

let data = searcbar(Characters, 'winnie the pooh')
console.log(data);

I nearly understood how the whole code works other than this part:

const searchalt = Charac.find(function(Naame, index){
            return Naame.name.toLowerCase() === name.toLowerCase()

Where does this function get its data from? Like I didn't give it any value, I cant understand where does it get from.

Thank you.

  • 2
    `Java`, or `JavaScript`? They're two very different languages. This definitely *looks* like JavaScript, though. – David Thomas Jan 23 '22 at 21:25
  • _“Like I didn't give it any value”_ — _You_’re not supposed to give it any value. The function is called _by JavaScript_ and is passed the values. Read the [documentation](//developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find). – Sebastian Simon Jan 23 '22 at 21:27

0 Answers0