Using JSON data in JavaScript
I recently wrote a JavaScript program that selects a random "advice number" between 1 and 50. Now, I need to figure out how to access a JSON file for the advice messages.
JavaScript file:
Advice_number = Math.floor(Math.random() * 50) + 1
console.log(Advice_number)
function Advice_picker() {
}
JSON file:
[
"When in the backrooms, keep your eyes low, for the walls have ears and the floors have eyes.",
"Beware the flickering lights, for they are whispers of entities unseen.",
"Navigate the endless halls with caution, for each turn may lead to another layer of despair.",
]
...
I have more advice messages in the JSON file
I've been searching for built-in functions to help connect the random number to the corresponding advice message, but haven't found any. If you know of any functions that could assist me with this, please let me know!