Solution: Logic

Review the solutions to the tasks from the logic challenge.

We'll cover the following...

Solution 1

Here is a possible solution for checking which number is bigger:

Explanation

  • Lines 1–2: Declares constant variables x and y, and assigns to them the values returned by the Number() function applied to the results of the prompt() function.

    • The prompt() function displays a dialog box in the browser where the user can input some text.

    • The Number() function then attempts to convert this input text into a numerical value.

  • Line 3: Declares a variable big using the let keyword and initializes it with the value of the variable x.

  • Lines 4–9: C ...