0
javascript toLowerCase()
question: why is here the right answer „Daveoxford“ and NOT „daveoxford“? var name = „Dave“; var school = „Oxford“; name.toLowerCase(); school.toLowerCase(); console.log(name + school); //the „“ in the code are both up. just dont know why this is here not working. 😒
7 ответов
+ 6
You have to save the value in a variable. For example
var name = "Dave";
var school = "Oxford";
name =name.toLowerCase();
school=school.toLowerCase();
console.log(name +school);
+ 4
You have to save the value in a variable. In your code you were printing the same variable but not the lowercase value
+ 1
Strings are immutable in JavaScript so the toLowerCase() will not alter the actual string until and unless the change is assigned to the string itself. Try writing-
name=name.toLowerCase();
school=school.toLowerCase();
+ 1
Mylisa_beth read the first statement of my answer which tells the reason behind that behaviour.
+ 1
thank you folks!!! 👏👏👏💪💪💪
0
You could also try console.log(name.toLowerCase());