Javascript:
function program() {
var input = [];
do {
var num = prompt('Enter a number, or nothing to continue');
if (num == 'nothing') {
break;
}
input.push(parseDouble(num));
} while (true);
var sorted = [];
return sorted;
}
function parseDouble(str) {
return parseFloat(str);
}
function program() {
var input = [];
do {
var num = prompt('Enter a number, or nothing to continue');
if (num == 'nothing') {
break;
}
input.push(parseDouble(num));
} while (true);
var sorted = [];
return sorted;
}
function parseDouble(str) {
return parseFloat(str);
}
- Ending the input sequence requires literally typing "nothing" (case-sensitive and everything).
- You've got to create a
parseDouble
method, because obviously you're not getting doubles otherwise. - Returns the array
sorted
.