index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My JavaScript</title>
</head>
<body>
<script src="main.js"></script>
</body>
</html>
main.js
'use strict';
// const command = Number(prompt('Menu 1, 2, 3 or 0 to exit'));
// console.log(`Menu ${command} processed.`);
//let command = Number(prompt('Menu 1, 2, 3 or 0 to exit'));
//while (command !== 0) {
// console.log(`Menu ${command} processed.`);
// command = Number(prompt('Menu 1, 2, 3 or 0 to exit'));
//}
let command;
do {
command = Number(prompt('Menu 1, 2, 3 or 0 to exit'));
if (command === 0) {
console.log('Exited');
} else {
console.log(`Menu ${command} processed.`);
}
} while (command !== 0);