Intermediate Algorithm Scripting - Everything Be True

Tell us what’s happening:
Describe your issue in detail here.

The test condition of value[2] == falsey[5] is failing even though both the value are same. Can anyone please explain why its happening and how to overcome this.

Your code so far

function truthCheck(collection, pre) {
  let key = true;
  let value = => item[pre]);
  let falsey = [false,0,'',null,undefined,NaN];
  for(let i=0; i<value.length; i++){
    for(let j=0; j<falsey.length; j++){
        key = false;

truthCheck([{name: "Pikachu", number: 25, caught: 3}, {name: "Togepi", number: 175, caught: 1}, {name: "MissingNo", number: NaN, caught: 0}], "number")

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Intermediate Algorithm Scripting - Everything Be True

Link to the challenge:

  1. NaN === NaN is never true

  2. You should use the idea of Falsy instead of checking against a special list. Falsy values act like a boolean False when used in a condition.

1 Like

Hi @JeremyLT , thanks, I got your point, applied it and it worked. I was doing extra work.
English is not my first language, so i have understand problem and I had to read your hint many times as well to get it.

1 Like

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