Skip to content

Instantly share code, notes, and snippets.

@ruddha2001
Created June 19, 2020 18:57
Show Gist options
  • Save ruddha2001/060412c568dd7f56e4710da873b881ab to your computer and use it in GitHub Desktop.
Save ruddha2001/060412c568dd7f56e4710da873b881ab to your computer and use it in GitHub Desktop.
// Declaring a variable adventure, which has a type of string array
const adventure: Array<string> = [
"India",
"USA",
"Canada",
"Japan",
"South Africa",
];
/**
* A function to print a random country name from the adventure array
*/
const randomAdventureGenerator = () => {
let randomNumber = Math.floor(Math.random() * 5); // Returns a random number from 0 to 4
console.log(`Your next new adventure will be in ${adventure[randomNumber]}`);
};
randomAdventureGenerator(); // Calling the randomAdventureGenerator function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment