Log It!


#1




I do not have any error but I'm not understanding the ogic behind the last if statement of my code. Up until that everything made sense. Could someone break it down for me?


if (hits.length === 0){
  console.log("Your name wasn't found!);
}
  else{
 console.log(hits);
}


#2

if (hits.length === 0){
  console.log("Your name wasn't found!);
}

hits.length means the length of the array named hits.if the length of that array is 0 it means there is nothing in that array.it simply means nothing is pushed(when you wrote if(some condition){hits.push}).so your name was not found.will it be 0 if your name is found?no,it won't.

if first condition is false then it'll print else statement that is your name what was contained in that array.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.