JavaScript

My use of .toLowerCase() I get no errors but would this be proper use

https://w.trhou.se/ka54gqbjsp
Hello could someone please check my use of toLowerCase() at line 23 & line 24.

1 Answer

Jassim Al-Hatem
Jassim Al-Hatem
16,940 Points

Yes, it's perfectly fine. As a matter of fact, using .toLowerCase() in conditional statements is preferable (to me) when comparing strings. For example:

var name = "Jassim";
if(name === "jassim"){
   console.log("won't work");
}
var name = "Jassim";
if(name.toLowerCase() === "jassim"){
    console.log("will work");
}

I know I stretched my answer, but I hope it helps.