-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemoji.js
37 lines (29 loc) · 952 Bytes
/
emoji.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
// 1. Using your loop of choice. Create a function that prints the pyramid below. (Show your personality by using your favorite emoji)
// function pyramid (n){
// let emoji = " "
// for (let i = 1; i <= n; i++){
// for (let j = 1; j <= i; j++){
// emoji += "*"
// }
// emoji += "\n"
// }
// }
let n = 5;
let emoji = "";
for (let i = 1; i <= n; i++) {
for (let j = 0; j < i; j++) {
emoji += "*";
}
emoji += "\n";
}
console.log(emoji);
// console.log(pyramid(5));
/* 2. Create a function that removes the first element of the array below and adds “kiwi” to the end of the array
let favoriteFruits = [“mango”, “lychee”, “rambutan”, “papaya”] */
favoriteFruits = ["mango","lychee", "rambutan", "papaya"]
function removeElements(favoriteFruits) {
favoriteFruits.shift();
favoriteFruits.unshift("kiwi");
return favoriteFruits
}
console.log(removeElements(favoriteFruits));