-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrays.js
58 lines (51 loc) · 1.92 KB
/
arrays.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// // let guestList = ["Jack", "Lara", "Jason", "Moshe", "Viki"];
// // checkUpper();
// // function checkUpper() {
// // let yourName = prompt("enter your name please!");
// // let UpperCase =
// // yourName.slice(0, 1).toUpperCase() +
// // yourName.slice(1, yourName.length).toLowerCase();
// // if (UpperCase == yourName) {
// // if (guestList.includes(yourName)) {
// // alert("you are invited to the party! ");
// // } else {
// // alert("you are not invited to the party");
// // }
// // } else {
// // alert(
// // "Please and your name again with an upperCase in the beginnig and the rest in lowerCase"
// // );
// // }
// // }
// // fizz buzz challenge
// let numbers = [];
// let count = 1;
// function addingNum() {
// if (count % 3 === 0 && count % 5 === 0) {
// numbers.push("fizzBuzz");
// } else if (count % 3 === 0) {
// numbers.push("fizz");
// } else if (count % 5 === 0) {
// numbers.push("buzz");
// } else {
// numbers.push(count);
// }
// count++;
// console.log(numbers);
// }
// addingNum();
// Who's Buying Lunch? Code Challenge
// You are going to write a function which will select a random name from a list of names. The person selected will have to pay for everybody's food bill.
// Important: The output should e returned from the function and you do not need alert, prompt or console.log. The output should match the example output exactly, including capitalisation and punctuation.
// Example Input
// ["Angela", "Ben", "Jenny", "Michael", "Chloe"]
// Example Output
// Michael is going to buy lunch today!
let namesArray = ["Moshe", "Bob", "Arthor", "Alina", "Nete"];
function whoPaying(names) {
let numberOfNames = names.length;
let randomNamesPosition = Math.floor(Math.random() * numberOfNames);
let randomName = names[randomNamesPosition];
alert(randomName + " is going to pay for the lunch today! ");
}
whoPaying(namesArray);