forked from RizeComputerScience/js-practice
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
112 lines (92 loc) · 2.53 KB
/
Copy pathscript.js
File metadata and controls
112 lines (92 loc) · 2.53 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
console.log("Hello World!");
//Resource 1
letteam="Chicago Sky";
letjersey=88;
lethasWonChampionship=false;
letstadiumLocation=null;
letnextGame;
constsport="basketball";
console.log(team);
console.log(jersey);
console.log(hasWonChampionship);
console.log(stadiumLocation);
console.log(nextGame);
console.log(sport);
letplayer={
name: "Kahleah Copper",
position: "Guard",
pointsPerGame: 18.7
};
console.log(player.name);//Kahleah Copper
player.pointsPerGame=19.2;
console.log(player.pointsPerGame);//19.2
player.isStarter=true;
player.numberOfGames=254;
console.log(player.numberOfGames);//254
//Resource 2
letemojis=["🥦","🍨","🍫","🥛"];
console.log(emojis);//["🥦", "🍨", "🍫", "🥛"]
emojis[2]="🧀";//Replaces 🍫 with 🧀
console.log(emojis);//["🥦", "🧀", "🍫", "🥛"]
emojis.push("🍗");
console.log(emojis);//["🥦", "🧀", "🍫", "🥛", "🍗"]
emojis.pop();//Removes 🍗
console.log(emojis);//["🥦", "🧀", "🍫", "🥛"]
console.log(emojis.length);//4
console.log(emojis);//["🥦", "🧀", "🍫", "🥛"]
//Resource 3
functiongreet(name){
console.log("Hello, "+name);
}
greet("Jordan");//Hello, Jordan
functioncheer(team,number){
return"Go "+team+"! We're number "+number+"!";
}
console.log(cheer("Sky",1));//Go Sky! We're number 1!
letscore=89;
if(score>=90){
console.log("You got an A!");
}elseif(score>=80){
console.log("You got a B!");
}else{
console.log("Keep studying!");
}
letname="John";
if(name==="John"){
console.log("Hi John!");
}else{
console.log("You're not John. . .");
}
for(leti=1;i<=5;i++){
console.log("Round "+i);
}
//Output:
//Round 1
//Round 2
//Round 3
//Round 4
//Round 5
letsports=["Basketball","Soccer","Tennis"];
for(leti=0;i<sports.length;i++){
console.log(sports[i]);
}
// Output:
// Basketball
// Soccer
// Tennis
functionrateSong(songName,rating){
if(rating===1||rating===2){
returnsongName+" is a bad song.";
}elseif(rating===3||rating===4){
returnsongName+" is a good song.";
}else{
returnsongName+" is an amazing song!";
}
}
letmySongs=["Bang!","The Dog Song","Karma"]
for(leti=0;i<mySongs.length;i++){
console.log(mySongs[i]+" is a jam!")
}
console.log(rateSong("Bang!",5));//Bang! is an amazing song!
console.log(rateSong("The Dog Song",2));//The Dog Song is a bad song!
console.log(rateSong("Karma",4));//Karma is a good song!