-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path24.js
41 lines (41 loc) · 1.92 KB
/
24.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
"use strict";
//24.More Conditional Tests: You don’t have to limit the number of tests you create to 10. If you want to try more comparisons, write more tests. Have at least one True and one False result for each of the following:
//• Tests for equality and inequality with strings
//• Tests using the lower case function
//• Numerical tests involving equality and inequality, greater than and less than, greater than or equal to, and less than or equal to
//• Tests using "and" and "or" operators
//• Test whether an item is in a array
//• Test whether an item is not in a array
const str1 = "Hello";
const str2 = "hello";
console.log(str1 === str2); // false
console.log(str1 !== str1); // true
// Test using the lower case function
const text1 = "Hello World";
const text2 = "hello world";
console.log(text1.toLowerCase() === text2); // true
// Numerical tests involing equality and inequality, greater then and less then, greater then or equal to , and less then or equal to
const num1 = 10;
const num2 = 5;
console.log(num1 === num2); // false
console.log(num1 !== num1); // true
console.log(num1 > num2); // true
console.log(num1 < num2); // false
console.log(num1 >= num2); // true
console.log(num1 <= num2); // false
// Tests using "and" and "or" operators
const x = 5;
const y = 10;
const z = 15;
console.log(x < y && x < z); // true , botha conditions are true
console.log(x < y || y > z); // true , at least one condition is true
console.log(x > y && y < z); // false , both conditions are false
console.log(x > y || y > z); // false, both condition are false
// Test Whether an item is in an array
const fruits = ['apple', 'orange', 'banana', 'grapes'];
console.log(fruits.includes('banana')); // true
console.log(fruits.includes('kiwi')); // false
// Test Whether an item is not in an array
const colors = ['red', 'green', 'blue', 'yellow',];
console.log(!colors.includes('purple')); // true
console.log(!colors.includes('green')); //false