LoginSignup
2
4

More than 5 years have passed since last update.

JavaScriptでおみくじプログラム

Last updated at Posted at 2019-01-06

こちらの YouTubeで利用したサンプルプログラムです。

JavaScriptでおみくじプログラムを作ってみよう
https://www.youtube.com/watch?v=AJC4Ap0XsYI&feature=youtu.be

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>おみくじ</title>

    <style>
        body {
            background-color: rgb(181, 241, 153);
        }
        p {
            text-align: center;
            font-size: 2em;
            margin-top: 100px;
        }
    </style>
</head>
<body>
    <script>
        // 大吉・吉・中吉・小吉・末吉・凶・大凶
        let kujis = ['大吉', '吉', '吉', '吉', '中吉', '中吉', '小吉', '小吉', '小吉', '末吉', '末吉', '凶', '凶', '大凶'];
        //console.log(kujis[0]);
        let kuji = Math.floor(Math.random() * kujis.length);
        //console.log(kuji);

        document.write('<p>あなたの今年の運勢は、' + kujis[kuji] + 'です</p>');
    </script>
</body>
</html>
2
4
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
2
4