admin管理员组文章数量:1311153
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.
本文标签: javascriptPrompt toLowerCase not executing correctlyStack Overflow
版权声明:本文标题:javascript - Prompt toLowerCase not executing correctly - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741873734a2402344.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论