how to get a random statement from an array in javascript
//get random value from array
var colors = ["red","blue","green","yellow"];
var randColor = colors[Math.floor(Math.random() * colors.length)];
// how to generate random words from an array
const Coins = ["Heads","Tails"]
let Generate = Math.floor((Math.random() * Coins.length));
console.log(Coins[Generate]) // this will print the outcome// List your array items
let Testing1 = ["put","things","here"]
let Generate = Math.floor((Math.random() * Testing1.length)); // Generates a number of the array.
// logs the result
console.log(Testing1[Generate])
Also in JavaScript:
- vue router implementation
- movable gui javascript
- get child element by class javascript
- js data object length
- too many open files react native
- plus minus hackerrank solution javascript
- install nodejs ubuntu 19.04
- javascript format price
- javascript find file extension from string
- import React, { memo } from 'react';
- js check if map contains key
- react native margin vs padding
- método pop javascript
- how to load localt ext file in js
- picker change event react native
- js opposite of preventdefault
- share data between livewire and alpine js
- js array of strings mongoose
- nuxtjs http multiple proxy
- how get parent element javascript
- async iife
- aos js cdn
- how create an index mongodb
- can't bookmark react router