first attempt to getting a random item from an array
This commit is contained in:
12
wally/app.js
12
wally/app.js
@@ -0,0 +1,12 @@
|
|||||||
|
const words = [
|
||||||
|
'red',
|
||||||
|
'car',
|
||||||
|
'bed'
|
||||||
|
];
|
||||||
|
|
||||||
|
function getRandomWord() {
|
||||||
|
console.log('function triggered');
|
||||||
|
return words[(Math.random() * (3 - 1) + 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log( getRandomWord() );
|
Reference in New Issue
Block a user