Let me know in the comments!
("b" + "a" + + "a" + "a").toLowerCase()
The Options are given as following
The question does look simple, but the answer will definitely blow your mind.
Did you get any of these? The interesting thing is - all the options provided above are wrong!
Answer in 5.
Let's break down the code step by step to understand WHY!:
"b" + "a"concatenates the strings resulting in
+ + "a"is trying to convert the string
"a"to a number and then concatenating it with the above string
"a"is not a valid numeric representation, the result of this conversion is
"ba" + NaNconcatenates the string
"ba"with the value
NaN, resulting in the string
"baNaN" + "a"concatenates the string
"baNaN"with the string
"a", resulting in the string
.toLowerCase()is then called on the string
"baNaNa". This method converts all characters in the string to lowercase, which further results in the string
So, the final output of the code is "banana".
Tell me how long it took you to answer this simple question in the comments!