freeCodeCamp/guide/english/javascript/tutorials/give-your-javascript-slot-m.../index.md

8 lines
379 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Give Your JavaScript Slot Machine Some Stylish Images
---
We've already set up the images for you in an array called images. We can use different indexes to grab each of these.
Here's how we would set the first slot to show a different image depending on which number its random number generates:
$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');