Client-Side Web Development - Graded Assignment #9

This assignment must be completed with Javascript constructs covered in the module.
The HTML file should not be modified in any way.

  1. In the file main.js, in which you completed the previous assignments, write some code so that when any key is pressed, the elements within the Bootstrap rows on the page are randomly shuffled.
  2. In your solution, you can use the following function, which shuffles the indices of an array of length n (e.g. the call get_shuffled_indices(4) might return the array [1, 3, 2, 0], or the array [0, 2, 1, 3] etc.).
    
    function get_shuffled_indices(n) { 
        const a = Array(n).fill().map((e, i) => i); 
        for (let l = n; l > 0; --l) { a.push(a.splice(Math.floor(Math.random() * l), 1)[0]); }
        return a;
    }		    

 

For a video demonstrating the required behaviour click here.

For information on submission deadline and grading of this assignment see the the Schedule and Notes page, below the table.