console.log(typeof(30 + 'years'));//string
console.log(Number(30 + 'years')); //NaN
You should note that when two numbers presented as stings are added together, the result is a string. Example;
console.log(typeof('2' + '3')); //string
console.log('2' + '3'); //23
console.log('2' * '3'); //6 console.log(typeof('2' * '3')); //number console.log('2' - '3'); //-1 console.log(typeof('2' - '3')); //number console.log('6' / '3'); //2 console.log(typeof('6' / '3')); //number console.log('6' % '3'); //0 console.log(typeof('6' % '3')); //number
Until the next article, KEEP CODING & SHARING.