The Moron Test – Your Best Complete Version

So you’ve been working at this problem and are likely ready to put this bit of JS to bed, but there is just a final bit of work to do. First you need to link to your scenes.js file for your best working model. You should test this against v5 of the code which includes the models scene specific events from last week’s problem set. If your scenes.js file works with that version of the code then you’ve accomplished the best version of the code for this class!

Tutorial

There is one bonus function added to the moron.js set of functions called moveIcon(i, left, top). It basically makes the repetitive work of resetting the location in the window of an icon based on their index value, left position, and top position a little easier. Feel free to try it out in your code.

//new function in moron.js
function moveIcon(i, left, top) {
    icons[i].style.left = `${left}%`
    icons[i].style.top = `${top}%`
}

//example implementation in scenes.js
//deployed within the main: function(icon, i)
//for a switch(clickCount), event on click two

case 2:
    //calling each index value
    icons[0].style.left = "71%"
    icons[0].style.top = "27%"

    //OR using the moveIcon(i, left, top)
    //function now in moron.js
    moveIcon(1, 20, 60)
    moveIcon(2, 20, 27)
    moveIcon(3, 50, 55)

    //replaced by the above moveIcon calls
    // icons[1].style.left = "20%"
    // icons[1].style.top = "60%"
    // icons[2].style.left = "20%"
    // icons[2].style.top = "27%"
    // icons[3].style.left = "50%"
    // icons[3].style.top = "55%"
    break

Problem Set

  • Test your scenes.js file against v5
  • Make any adjustments needed to get your code working (for example add color variables if you wish)
  • If you’re adventurous consider playing with v6beta of the code which adds scene[level].start and scene[level].finish methods. There’s a number of other changes from v5 in there to grapple with, but if you’re up for learning how to add delays, additional screens that are before the scene[level].main, you can do it.

Blogging Assignment

Post your scenes.js file and describe any issues with the scene levels. Reference the scenes they based on from the original moron test breakdown. If you worked on any additional features to your code, create a v6beta of your own and post all files: moron.js, scenes.js, index.html, style.css. Please describe what features you’ve added and how.

Leave a comment

Your email address will not be published. Required fields are marked *