如何制作一个字符串变量,这是通过它的数字进行的?例如,大写A为65。ASCII图表
我想拥有它,以便提示用户输入第二个字符串,该字符串将比第一个字符串以比第一个字符串较低。我不明白如何使字符串成为一个数字?我什至需要这样做吗?
function SortStringAlphabetically() {
// Declare variables
var stringOne = "";
var stringTwo = "";
var output;
// Get input from user
stringOne = prompt("Please enter a string");
stringTwo = prompt("Please enter enter a string that will sort lower alphabetically than the first string.");
// Convert input strings to numbers
stringOne = Number(stringOne);
stringTwo = Number(stringTwo);
if ( stringTwo > stringOne) {
output = "very good" + stringOne + "sorts lower than" + stringTwo + ".";
} else {
output = stringOne + "sorts higher than" + stringTwo + "try again";
}
document.write(output);
}
// Run the program
SortStringAlphabetically();
// END OF YOUR CODE
I want to have it so the user is prompted to enter the second string, that will sort lower alphabetically than the first string. I don't understand how to make a string a number? Do I even need to do that?
function SortStringAlphabetically() {
// Declare variables
var stringOne = "";
var stringTwo = "";
var output;
// Get input from user
stringOne = prompt("Please enter a string");
stringTwo = prompt("Please enter enter a string that will sort lower alphabetically than the first string.");
// Convert input strings to numbers
stringOne = Number(stringOne);
stringTwo = Number(stringTwo);
if ( stringTwo > stringOne) {
output = "very good" + stringOne + "sorts lower than" + stringTwo + ".";
} else {
output = stringOne + "sorts higher than" + stringTwo + "try again";
}
document.write(output);
}
// Run the program
SortStringAlphabetically();
// END OF YOUR CODE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论