forked from HackYourFuture/Assignments
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathex3-tellFortune.js
More file actions
34 lines (23 loc) · 961 Bytes
/
ex3-tellFortune.js
File metadata and controls
34 lines (23 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function selectRandomly(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
export function tellFortune(numKids, partnerNames, locations, jobTitles) {
return `You will be a ${selectRandomly(jobTitles)} in ${selectRandomly(
locations
)}, married to ${selectRandomly(partnerNames)} with ${selectRandomly(
numKids
)} kids.`;
}
function main() {
const numKids = [0, 1, 2, 3, 4];
const partnerNames = ["Alex", "Sam", "Taylor", "Jordan", "Casey"];
const locations = ["Amsterdam", "Rotterdam", "Utrecht", "The Hague", "Eindhoven"];
const jobTitles = ["developer", "designer", "teacher", "engineer", "chef"];
console.log(tellFortune(numKids, partnerNames, locations, jobTitles));
console.log(tellFortune(numKids, partnerNames, locations, jobTitles));
console.log(tellFortune(numKids, partnerNames, locations, jobTitles));
}
// ! Do not change or remove the code below
if (process.env.NODE_ENV !== 'test') {
main();
}