Can we simplify case sensitive? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can we simplify case sensitive?

in example i have this code : if (x == "one" || x == "One" || x == "ONE" || ..... ) { // statements } is there any method or function or syntax so it's not necessary to type the case sensitive one by one? Thank you, Master

9th Oct 2020, 10:32 AM
Wan
Wan - avatar
5 Answers
+ 5
var a = input.value; var b = a.value.toLowerCase(); https://code.sololearn.com/WUteJzI5p7SZ/?ref=app Check this old code of mine
9th Oct 2020, 10:34 AM
Gabriele Gatti
Gabriele Gatti - avatar
+ 5
Wan Sorry I forgot to write them before. Now I have fixed my answer.
9th Oct 2020, 11:06 AM
Gabriele Gatti
Gabriele Gatti - avatar
+ 2
toLowerCase() is a function so you should include parenthesis at the end.
9th Oct 2020, 10:54 AM
Avinesh
Avinesh - avatar
+ 1
Thank you, i modified my code to : ... var x = prompt ("say yes"); var y = x.toLowerCase(); alert(y); .... and it's worked 👍🏻
9th Oct 2020, 10:59 AM
Wan
Wan - avatar
0
it doesn't work in this my code : ... var x = prompt ("say yes"); var y = x.toLowerCase; alert(y); .... result : " function toLowerCase() {[native code]} "
9th Oct 2020, 10:50 AM
Wan
Wan - avatar