0

In the following code my false condition doesn't work, I have made sample program:

const path = require("path");
const fs = require("fs");
module.exports = async function(callback) 
{
   try {
      let keywordStr = '11 =  cccc =        (bbbb sssss )= ttttttttt("")';
      let words =   keywordStr.split(' '); //number of lines in file
      
      for (let i = 0; i <words.length; i++) { 
         word= words[i]
         console.log("word =" + word)
         //NaN = not a number
         if (isNaN(word) === false && word !== null){//if(isNaN(word)==false  && word !== null){
            console.log("testing2 new numeric string = " + word);
         }
      }
    }
    catch (error) {
          console.log(error)
    }
    callback();
}

I just want to print: testing2 new numeric string = 11

but both "false" value and null value not working in the above if-condition: $ truffle exec findnumeric.js

$ truffle exec findnumeric.js

Using network 'development'.

word =11
testing2 new numeric string = 11
word ==
word =
testing2 new numeric string = 
word =cccc
word ==
word =
testing2 new numeric string = 
word =
testing2 new numeric string = 
word =
testing2 new numeric string = 
word =
testing2 new numeric string = 
word =
testing2 new numeric string = 
word =
testing2 new numeric string = 
word =
testing2 new numeric string = 
word =(bbbb
word =sssss
word =)=
word =ttttttttt("")

Somebody please guide me.

Zulfi.

1 Answer 1

0

This problem has been solved. Actually I did not know that '' and null are not same things in javascript.

Following link provides the corrected code: code forum link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.