Javascript syntax function issue -
why following code work shouldn't title set lowercase causing second if statement fail?
var title = 'random_letters'; if(title.tolowercase() == 'random_letters') { //this fire } if(title == 'random_letters') { //this still fire variable not saved lowercase }
you aren't changing value of variable. can prove printing out value of variable @ each step.
var title = 'random_letters'; console.log(title); // here, title "random_letters" if(title.tolowercase() == 'random_letters') { console.log(title); // here, title still "random_letters" } console.log(title); // here, title "random_letters" if(title == 'random_letters') { //we line, our title still "random_letters" } according docs (https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/tolowercase), value of string using method not affected.
Comments
Post a Comment