Q:

Comparing two variables JavaScript

I am new to programming and JavaScript so please bear with me if its a stupid question.
I initialised two variables
let firstName = "blah";
let FirstName = "bleh";

When i write a below if statement i expected the output to be "right on" since the variable names are different (case-sensitive), but i get "boink". Could anyone kindly explain whats happening here?
if (firstName = FirstName) {
    console.log('boink')
} else {
    console.log('right on')
}

A:

Could anyone kindly explain whats happening here

Actually firstName = FirstName is an Assignment expression and it will return the value on the right handside which is "bleh" which is truthy value. So the first block is executed
You are using assignment operator you need to use comparison operator(== or ===)

let firstName = "blah";
let FirstName = "bleh";

if (firstName === FirstName) {
    console.log('boink')
}
else {
    console.log('right on')
}

