Files
freeCodeCamp/common/app/utils/get-words.js
2018-06-02 03:32:37 +05:30

22 lines
422 B
JavaScript

import words from './words.json';
function randomItem(arr) {
return arr[ Math.floor(Math.random() * arr.length) ];
}
export function randomQuote() {
return randomItem(words.motivationalQuotes);
}
export function randomPhrase() {
return randomItem(words.phrases);
}
export function randomVerb() {
return randomItem(words.verbs);
}
export function randomCompliment() {
return randomItem(words.compliments);
}