Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

193 - Step 2 Create A New Pattern.html 2.7 KB

You have to be logged in to leave a comment. Sign In
1
  1. <p>1. Inside <strong>game.js</strong> create a <strong>new function</strong> called <code>nextSequence()</code></p><p>2. <strong>Inside</strong> the new function generate a new <strong>random number</strong> between <strong>0</strong> and <strong>3</strong>, and store it in a <strong>variable</strong> called <code>randomNumber</code> </p><p>You can use the Chrome console to verify that your code creates random numbers between the correct range. </p><figure><img height="207" src="https://img-b.udemycdn.com/redactor/raw/2018-11-22_10-29-46-f35b1b67fdc733fee6b115ffa13d6930.png" width="259"></figure><p>3. At the top of the <strong>game.js </strong>file, create a new <strong>array</strong> called <code>buttonColours</code> and set it to hold the sequence <code>"red", "blue", "green", "yellow"</code> .</p><p>4. Create a new variable called <code>randomChosenColour</code> and use the <code>randomNumber</code> from step 2 to select a random colour from the <code>buttonColours</code> array.</p><p>5. At the top of the <strong>game.js </strong>file, create a new empty array called <code>gamePattern</code>.</p><p>6. Add the new <code>randomChosenColour</code> generated in step 4 to the end of the <code>gamePattern</code>.</p><p><br></p><p>Note: If you need any hints, try scrolling down. 👇</p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p>Hint 1. Remember this is how you create and call functions in JavaScript:</p><figure><img src="https://img-b.udemycdn.com/redactor/raw/2018-11-21_10-49-16-dbc2029ddafc91ff42f957991183f40f.png"></figure><p><br></p><p>Hint 2A. Remember this is how you generate random numbers between 0 and 0.9999...</p><figure><img src="https://img-b.udemycdn.com/redactor/raw/2018-11-21_10-54-49-dac0c523ff494299585241f4f0f9f9c5.png"></figure><p>Hint 2B. Remember this is how you round down a number.</p><figure><img src="https://img-b.udemycdn.com/redactor/raw/2018-11-21_10-56-32-94e4bcb5449f8685596a9d5140b3c55d.png"></figure><p>Hint 3. Remember this is how arrays are created in JavaScript:</p><figure><img src="https://img-b.udemycdn.com/redactor/raw/2018-11-21_10-59-38-052565b0de9dc8cec5d67ab8a7a84053.png"></figure><p>Hint 4. Remember this is how you select items inside arrays:</p><figure><img src="https://img-b.udemycdn.com/redactor/raw/2018-11-21_11-20-00-0f9c30930f660a2a95faa6975cd75a68.png"></figure><p>Hint 6. Remember this is how you add new items to arrays:</p><figure><img src="https://img-b.udemycdn.com/redactor/raw/2018-11-21_11-17-26-1e31d6dbe809a3cf701896e4e93c8983.png"></figure>
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...