Created
April 21, 2018 02:35
-
-
Save jonathandavidpollock/ac8f7311aa6e02413f8b105e0294cb7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = () => { | |
console.log('Inside the JS function'); | |
// find the image elements | |
let imgArray = document.querySelectorAll('.random_image'); | |
console.log(`Found all of these images: ${imgArray}`) | |
// Randomly pick a number | |
// Locate the image based off Random Number | |
const num = Math.floor(Math.random()*imgArray.length); | |
const imageToDisplay = imgArray[num]; | |
console.log(`We choose this number for the random image: ${num}`); | |
console.log(`${imageToDisplay}`); | |
// He the image that are not the image chosen | |
for(let i = 0; i <= imgArray.length; i++){ | |
if(i !== num) { | |
imgArray[i].remove(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment