-
Notifications
You must be signed in to change notification settings - Fork 175
/
comparisons.js
72 lines (52 loc) · 2.21 KB
/
comparisons.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// In the exercises below, write your own code where indicated to achieve the desired result.
// One example is already completed. Your task is to complete any remaining prompt.
// Make sure to run the file in your command line using `node <filename>.js`
// -------------------
// PART 1: Comparing variables
// -------------------
var numberTeachers = 4
var numberStudents = 20
var stringTeachers = "4"
var numberDogs = 0
// EXAMPLE: log the result of the comparison: is numberTeachers greater than numberStudents?
console.log("Is numberTeachers greater than numberStudents?", numberTeachers > numberStudents);
// this should log: "Is numberTeachers greater than numberStudents?" false
// YOU DO: log the result of the comparison: is numberTeachers strictly equal to stringTeachers?
// this should log: false
// YOU DO: log the result of the comparison: is numberTeachers not equal to numberStudents?
// this should log: true
// YOU DO: log the result of the comparison: is numberStudents greater than or equal to 21?
// this should log: false
// #-------------------
// PART 2: Articulating what you are doing
// #-------------------
// For the following prompts, you will be given a line of code and your task is to type out a comment,in English, explaining what that line of code is doing, including what the comparison will evaluate to.
var friends = 6;
var siblings = 2;
console.log(friends > siblings);
// YOU DO: Explain.
var attendees = 9;
var meals = 8;
console.log(attendees !== meals);
// YOU DO: Explain.
// #-------------------
// PART 3: Logical Operators
// #-------------------
var isHungry = true;
var finishedHomework = false;
// EXAMPLE:
// Determine if the user is hungry and has completed their homework
console.log(isHungry && finishedHomework);
// Determine if the user is hungry or has completed their homework
console.log(isHungry || finishedHomework);
var lovesToPlay = true;
var lovesDogPark = false;
var lovesTreats = true;
var age = 1;
// YOU DO:
// Determine if the dog loves to play and loves treats
// YOU DO:
// Determine if the dog loves to play or loves the dog park
// YOU DO:
// Determine if the dog loves to play and is a puppy
// HINT: Use the age variable and assume that a puppy is less than 2 years old