20.04.2020
HOME
15.04.2020
16.04.2020
21.04.2020
22.04.2020
23.04.2020

Summary

Topics

Class

Exercise

Reading time

Topics HOME

JavaScript engine

DOM

HTML <script> element (inline and external script)

Window interface

Native object (global object) and Host object

Class HOME DCI Class Repository

DOM

Hey, welcome to my page

cool this is me 🤓



Exercise HOME

The Guessing Game

Create a guessing game for players.

Instructions:

  1. Randomize a number between 1 - 10 (do not show to the player);
  2. Make the player guess the number in a prompt;
  3. If the player guesses the correct number, print out whether
    the player was successful and in how many attempts
    (print in the console);
  4. If the player is incorrect, change the text in the prompt
    to inform the player, e.g. "Nope, sorry! Try again!"
  5. If the player fails to guess the number after three attempts,
    print out that the player was unsuccessful AND what the number was.
    e.g. "Sorry, you failed to guess the number in three attempts. The number was 0!"

Solution:

    The Guessing Game

    The Guessing Game v2
Repositories:

General / HTML / JavaScript

References:

Math.random()

while statement

Window.prompt()

Window.alert()

Reading time HOME

What is the Document Object Model?

Document

Document.getElementById()