0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Javascript 入力内容をもとにアクションを変える

Last updated at Posted at 2022-04-08

はじめに

javascriptでプロンプトをだして入力した値で分岐する

教科書

実行内容

yesと入力されたら次のメッセージをだす。違う場合は無反応
<script>
    'use strict';

    const answer = window.prompt('ヘルプを見ますか?');
    if (answer === 'yes') {
        window.alert('タップでジャンプ、障害物を避けます');
    }
    console.log(answer);
</script>

メモ

let answerで変数のanswerになり後から中身を変更可能
const answerで定数のanswerになり後から変更は不可能

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?