Common mistakes that every new JavaScript programmer does

Most common mistakes done by new developers:

Addition and Concatenation:

While adding the number.


let a=5;
let b="5";
let c=a+b;
console.log(c) // returns 55;

To avoid this Addition issue use the Number function to convert the values:

let a=5;
let b="5";
let c=Number(a)+Number(b);
console.log(c) // returns 10;

In order to check the values type, conditional write the code and add the number.

Else use the parseInt and convert the number.

To Read More about ParseInt goHere


Using  == operators

if(2 == '2') {

this == always checks the values and this will not check the type of values.

To Avoid this use === to compare the values:

if( 2 === '2' ) {

Leave a Comment