diff --git a/app.js b/app.js new file mode 100644 index 000000000..4f72bdb2f --- /dev/null +++ b/app.js @@ -0,0 +1,141 @@ +//1. +let englishGreeting = "Hello, World!" +console.log(englishGreeting); +let kurdishGreeting = "Silav, Cihan!" +console.log(kurdishGreeting); +let dutchGreeting = "Hoi, Wereld!" +console.log(dutchGreeting); + +//2. +let me = "I'm awesome!" +console.log(me); + +//3.1 +let x; + +//3.2 +console.log("I think the value of x will be: undefined"); + +//3.3 +console.log(x); + +//3.4 +let x = 6; + +//3.5 +console.log("the value of x is: 6"); + +//3.6 +console.log(x); + +//4.1 +let y ="Sivan"; + +//4.2 +console.log("I think the value of y is a name"); + +//4.3 +console.log(y); + +//4.4 +const y = "Hassam"; + +//4.5 +console.log("There will be an error because now I have the same variable with different values."); + +//4.6 +console.log(y); + +//5. +const z = 7.25; + +//5.1 +console.log(z); + +//5.2 +const a = z; + +//5.3 +console.log(a); + +//5.4 +var round =Math.round(7.25); + +//5.6 +console.log(round) + +//6.1 +let arrays; + +//6.2 +console.log("I think the value will be undefined"); + +//6.3 +console.log(arrays); + +//6.4 +let myFavoriteAnimals = ['cat', 'dog', 'sheep']; + +//6.5 +console.log(myFavoriteAnimals); + +//6.6 +const animals = myFavoriteAnimals.push('baby pig'); + +//6.7 +console.log(animals); + +//7.1 +let myString = "this is a test"; + +//7.2 +console.log(myString); + +//7.3 +console.log(myString.length); + +//8.1 +let num = 11; +let address = "Huygenhoekring"; +let supermarkets = ["Lidl", "Dekka", "Jumbo"]; +let booleans = true, false, true; + +//8.2 +console.log(num); +console.log(address); +console.log(supermarkets); +console.log(booleans); + +//8.3 +console.log("I think the type of num is number, type of address is string, type of supermarkets is array and type of booleans is boolean."); + +//8.4 +console.log(typeof num); +console.log(typeof supermarkets); +console.log(typeof booleans); +console.log(typeof address); + +//8.5 +if (num != address) { + console.log("num is a number and address is a string"); +} + +//9.1 +let s = 7; +let v = 3; +let h = s % 3; +console.log(s % h); +console.log(s % v); +console.log(v % h); + +//10.1 +const mix = [5, "Shvan"]; +console.log(mix); + +//10.2 +var maxNumber = Math.pow(6/0); + +//10.2 +if (maxNumber === Infinity){ +console.log(0 / maxNumber); +} diff --git a/week3.js b/week3.js new file mode 100644 index 000000000..c9ba185a6 --- /dev/null +++ b/week3.js @@ -0,0 +1,131 @@ +//String +let myString = "Hello,this,is,a,difficult-,to-,read,sentence"; +console.log(myString); +console.log(myString.length); +myString = myString.replace(/,/g, " "); +console.log(myString); + +//Arrays +let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; +console.log(favoriteAnimals); + +let favoriteAnimalsOfMauro = ["blowfish", "capricorn", "giraffe", "turtle"]; +console.log(favoriteAnimalsOfMauro); + +let favoriteAnimalsOfJim = ["blowfish", "meerkat", "capricorn", "giraffe", "turtle"]; +console.log("The favorite animal of Jim is added to the array."); +console.log(favoriteAnimalsOfJim); +console.log("The array has a length of:", favoriteAnimalsOfJim.length); + +let favoriteAnimalsOfJason = ["blowfish", "meerkat", "capricorn", "turtle"]; +console.log(favoriteAnimalsOfJason); +console.log(favoriteAnimalsOfJason.length); +console.log(favoriteAnimalsOfJason[1], "The item you are looking for is at index:2"); + +//JavaScript +function sum(a, b, c) { + return a + b + c; +} +console.log(sum(5, 3, 2)); +//2. +function colorCar(color){ + return "A" + color + "car"; + } + console.log(colorCar("red")); +//3. +let country = {Land: "The Netherlands", Population:"17 million", Capital:"Amsterdam"}; +console.log(country); +console.log(country.Land); +console.log(country.Population); +//4. +function vehicleType(color, code){ + if (code === 1){ + console.log("A" + color + "car"); +} else if (code === 2){ +console.log("A" + color + "motorbike");} +} +vehicleType("blue", 2); +//5. +3===3 ? console.log("Yes") : console.log("No"); +//6 +function vehicle(color, code, age){ + if (code === 1 || age > 5){ + console.log("A" + "" + color + "" + "used car"); +} else if (code === 2 || age < 5){ + console.log("A" + "" + color + "" + "new car"); +} + } +vehicle("blue", 1, 5); +//7. +const vehicleList = [ + "motorbike", + "caravan", + "bike", + "bicycle", + "car" +]; +console.log(vehicleList.length); +console.log(vehicleList[2]); + +//9 +function newVehicle(color){ + if (vehicleList[2] = 3){ + console.log("A" + "" + color + "" + "new" + "" + "bike"); + } else (vehicleList[2] > 3);{ + console.log("A" + "" + color + "" + "old" + "" + "bike") + } +} +newVehicle("green", 3, 1); + +//10 +const advertisement = vehicleList; +console.log(advertisement); +for (let index = 0; index < advertisement; index++) { + console.log(advertisement[index]); +} +if (advertisement.length = 5) { + console.log("Amazing Joe's Garage >>> Here we service cars, motorbikes, caravans and bikes."); +}else { + console.log("Amazing Joe's Garage >>> Here we service bulldozers, lorries and trucks."); +} +//11 +const newVehicleList = advertisement + "" + "scooter"; +console.log(newVehicleList); +//12. +let object; +//13+14 +let teachers = {Philip: "HTML/CSS", Rob: "HTML/CSS", Hardit: "CLI", Bonan: "CLI", Ogor: "CLI", Unmesh: "GIT", Marciano: "JS", Sander: "JS"}; + +//15 +let x = [1, 2, 3]; +let y = [1, 2, 3]; +let z = y; +console.log(x == y); +console.log(x === y); + +console.log(x == z); +console.log(x === z); + +console.log(y == z); +console.log(y === z); + +//16. +let o1 = { foo: "bar" }; +let o2 = { foo: "bar" }; +let o3 = o2; +console.log(o1); +console.log(o2); +console.log(o3); +//Do you mean to make new ones? +let o1New = {quur: "quuur"}; +let o2New = {quur: "quuur"}; +let o3New = o2New; +console.log(o1New); + +//17. +let bar = 42; +typeof typeof bar; +console.log(typeof bar); //->> number. +console.log(typeof typeof bar); //->> string. + +//the end. \ No newline at end of file