Skip to content

Instantly share code, notes, and snippets.

@omas
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save omas/40b83a2135be438c0be9 to your computer and use it in GitHub Desktop.

Select an option

Save omas/40b83a2135be438c0be9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<!--
1.コマンドラインに入力を待ち受けるための「>」を表示する。
2.標準入力された値があればそのまま表示、値がなければ「未入力です」と表示して、再び入力待ち受け状態にする。
3.「EXIT」が入力された時点でプログラムを終了する。
-->
<script>
(function(){
while(true){
var input = prompt(">"); //condition 1
if (input === "EXIT") break; //condition 3
if (input) { //condition 2
output(input);
} else {
output("未入力です");
}
}
})();
function output(text){
alert(text);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment