I'm unsure why this isn't executing properly? It's so simple however I can't warp my head around it:
response = prompt(question.toLowerCase());
When I insert something into the prompt and I console.log it it seems to e back with uppercase letter that I added when I inserted the value into the prompt.
I want toLowerCase to convert any value into lowercase when submitted.
Any idea why this isn't working?
I'm unsure why this isn't executing properly? It's so simple however I can't warp my head around it:
response = prompt(question.toLowerCase());
When I insert something into the prompt and I console.log it it seems to e back with uppercase letter that I added when I inserted the value into the prompt.
I want toLowerCase to convert any value into lowercase when submitted.
Any idea why this isn't working?
Share Improve this question asked Dec 26, 2015 at 11:29 Nicholas MaddrenNicholas Maddren 1555 silver badges12 bronze badges2 Answers
Reset to default 9It's because you are setting lower caption of prompt, not the entered text. You have to use:
response = prompt(question).toLowerCase();
As you want toLowerCase()
to convert any user response to lowercase, try
resp = prompt('Blah blah', '')
lcrp = response.toLowerCase();
As prompt
or window.prompt
accepts two arguments, one for the message to be displayed in the prompt and another as a default if the user did not provide any response.
prompt
returns the user input as a string. So, resp.toLowerCase()
should convert resp
to lowercase.