|
| 1 | +//1 |
| 2 | +let EnglishGreeting = "Hello world!"; |
| 3 | +console.log (EnglishGreeting) |
| 4 | +let ArabicGreeting = "مرحباً بالعالم"; |
| 5 | +console.log (ArabicGreeting) |
| 6 | +let ItalianGreeting = "Ciao Mondo!"; |
| 7 | +console.log (ItalianGreeting) |
| 8 | +let TurkishGreeting = "Selam Dünya!"; |
| 9 | +console.log (TurkishGreeting) |
| 10 | +let DutchGreeting = "Hallo Wereld!"; |
| 11 | +console.log (DutchGreeting) |
| 12 | + |
| 13 | +//2 |
| 14 | +console.log ('I\'m awesome'); |
| 15 | + |
| 16 | +//3 |
| 17 | +let x ; |
| 18 | +console.log ("the value of my variable x will be:EvenNumber"); |
| 19 | +console.log (x); |
| 20 | +x = 8 ; |
| 21 | +console.log ("the value of my variable x will be:EvenNumber"); |
| 22 | +console.log (x) |
| 23 | + |
| 24 | +//4 |
| 25 | +let y = "HackYourFuture" |
| 26 | +console.log ("the value of the string is "+"HackYourFuture") |
| 27 | +console.log (y) |
| 28 | +y = "HYF" |
| 29 | +console.log ("the value of the string is "+"HYF") |
| 30 | +console.log (y) |
| 31 | + |
| 32 | +//5 |
| 33 | +let z = 7.25; |
| 34 | +console.log(z); |
| 35 | +let a = (Math.round(z)); |
| 36 | +console.log(a); |
| 37 | + |
| 38 | +let highest; |
| 39 | +if (z>a){ |
| 40 | + highest=z; |
| 41 | +} |
| 42 | +else{ |
| 43 | + highest=a; |
| 44 | +} |
| 45 | +console.log(highest); |
| 46 | + |
| 47 | + |
| 48 | +//6 |
| 49 | +let FavoriteAnimals = [ ]; //6.1 |
| 50 | +console.log("the value of my array is : Empty."); //6.2 |
| 51 | +console.log(FavoriteAnimals); //6.3 |
| 52 | +let MyFavoriteAnimals = [ 'Deer' , 'Horse' , 'Koala' ]; //6.4 |
| 53 | +console.log (MyFavoriteAnimals); //6.5 |
| 54 | +let NewMyFavoriteAnimals = MyFavoriteAnimals.concat(['baby pig']); //6.6 |
| 55 | +console.log (NewMyFavoriteAnimals); //6.7 |
| 56 | + |
| 57 | +//7 |
| 58 | +let myString = "this is a test"; |
| 59 | +console.log(myString); |
| 60 | +console.log(myString.length); |
| 61 | + |
| 62 | +//8 |
| 63 | +let type1 = 21 ; |
| 64 | +console.log ("The value of my variable type1 is: " + type1); |
| 65 | +console.log (typeof(type1)); |
| 66 | +let type2 = ['HTML', 'CSS'] ; |
| 67 | +console.log ("The value of my variable type2 is: " + type2); |
| 68 | +console.log (typeof(type2)); |
| 69 | +let type3 = " Hello JavaScript " ; |
| 70 | +console.log ("The value of my variable type3 is: " + type3); |
| 71 | +console.log (typeof(type3)); |
| 72 | +let type4 = "Class21" ; |
| 73 | +console.log ("The value of my variable type4 is: " + type4); |
| 74 | +console.log (typeof(type4)); |
| 75 | + |
| 76 | +//8.5 |
| 77 | +if (typeof(type1)===typeof(type2)) |
| 78 | +{console.log('type1 and type2 are SameType');} |
| 79 | +else {console.log('type1 and type2 are NOT SameType');} |
| 80 | + |
| 81 | +if (typeof(type1)===typeof(type3)) |
| 82 | +{console.log('type1 and type3 are SameType');} |
| 83 | +else {console.log('type1 and type3 are NOT SameType');} |
| 84 | + |
| 85 | +if (typeof(type1)===typeof(type4)) |
| 86 | +{console.log('type1 and type4 are SameType');} |
| 87 | +else {console.log('type1 and type4 are NOT SameType');} |
| 88 | + |
| 89 | +if (typeof(type2)===typeof(type3)) |
| 90 | +{console.log('type2 and type3 are SameType');} |
| 91 | +else {console.log('type2 and type3 are NOT SameType');} |
| 92 | + |
| 93 | +if (typeof(type2)===typeof(type4)) |
| 94 | +{console.log('type2 and type4 are SameType');} |
| 95 | +else {console.log('type2 and type4 are NOT SameType');} |
| 96 | + |
| 97 | +if (typeof(type3)===typeof(type4)) |
| 98 | +{console.log('type3 and type4 are SameType');} |
| 99 | +else {console.log('type3 and type4 are NOT SameType');} |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +//9 |
| 106 | +let X = 7 ; |
| 107 | +X = X % 3; |
| 108 | +console.log(X = X % 3); |
| 109 | +console.log(X %= 3); |
| 110 | +console.log(X); |
| 111 | + |
| 112 | +//10.1 |
| 113 | +let multipleTypesArray = ['class', 21 , true]; |
| 114 | +console.log(typeof(multipleTypesArray[0])); |
| 115 | +console.log(typeof(multipleTypesArray[1])); |
| 116 | +console.log(typeof(multipleTypesArray[2])); |
| 117 | + |
| 118 | +//10.2 |
| 119 | +let x1 = 6/0; |
| 120 | +let y1 = 10/0; |
| 121 | +x1 === y1? console.log('Yes') : console.log('No'); |
0 commit comments