diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..d8dea71b8 Binary files /dev/null and b/.DS_Store differ diff --git a/Week1/.DS_Store b/Week1/.DS_Store new file mode 100644 index 000000000..953c6cdc4 Binary files /dev/null and b/Week1/.DS_Store differ diff --git a/Week1/homework/start.js b/Week1/homework/start.js new file mode 100644 index 000000000..24b56b707 --- /dev/null +++ b/Week1/homework/start.js @@ -0,0 +1,105 @@ +//JavaScrip Exercise Week2 +//https://github.com/HackYourFuture/JavaScript1/blob/master/Week2/MAKEME.md +//1.Write hello world +console.log('Hello world!'); + +//2.SyntaxError +console.log('I\'m awesome'); +console.log("I'm awesome"); + +//3.Declare a variable +var x; +console.log('the value of my variable x will be: 5'); +console.log(x); +x = 5; +console.log('I think the value of x is 5 '); +console.log('the real value is: ' + x); + +//4.assign different values to String variable +var y = 'Melody'; +console.log('I think the value of y is: Melody') +console.log(y); +y = 'Vesal'; +console.log('I think the value of y now is: Vesals'); +console.log(y); + +//5.maximum number +var z = 7.25; +console.log(z); +var a = parseInt(7.25); +console.log(a); +var highest_value = Math.max(a, z); +console.log("the highest value between " + z + " and " + parseInt(z) + " is " + highest_value); + +//6.Arrays +var elements = []; +console.log('I think the array value is empty'); +console.log(elements); +var my_favorite_animals = ['Hourse', 'Dog', 'Tiger']; +console.log(my_favorite_animals); +my_favorite_animals.push('Baby Pig'); +console.log(my_favorite_animals); + +//7.More strings +let myString = "this is a test"; +console.log(myString); +console.log(myString.length); + +//8.check variables type +let var_1 = 'hello'; +let var_2 = 12.65; +let var_3 = true; +let var_4 = null; +let var_5 = undefined; + +console.log('The value of my variable var_1 is: ' + var_1); +console.log('The value of my variable var_2 is: ' + var_2); +console.log('The value of my variable var_3 is: ' + var_3); +console.log('The value of my variable var_4 is: ' + var_4); +console.log('The value of my variable var_5 is: ' + var_5); + +console.log('I think the type of var_1 is: String '); +console.log('I think the type of var_2 is: Number '); +console.log('I think the type of var_3 is: Boolean '); +console.log('I think the type of var_4 is: Object '); +console.log('I think the type of var_5 is: Undefined '); + +console.log(typeof(var_1)); +console.log(typeof(var_2)); +console.log(typeof(var_3)); +console.log(typeof(var_4)); +console.log(typeof(var_5)); + +if(typeof(var_1) == typeof(var_2)){ + console.log(var_1 + " and " + var_2 + " are the SAME TYPE") +} +else { + console.log(var_1 + " and " + var_2 + " are NOT the SAME TYPE") +} + +if(typeof(var_2) == typeof(var_3)){ + console.log(var_2 + " and " + var_3 + " are the SAME TYPE") + } +else { + console.log(var_2 + " and " + var_3 + " are NOT the SAME TYPE") +} + +if(typeof(var_4) == typeof(var_5)){ + console.log(var_4 + " and " + var_5 + " are the SAME TYPE") + } +else { + console.log(var_4 + " and " + var_5 + " are NOT the SAME TYPE") +} + +//9.Number Division and Mod (Remainder of Division) +var x = 7; +console.log('The value of ' + x + ' % ' + 3 + ' is: ' + (x % 3)); +console.log('The value of (10 % 2) is: ' + 10 % 2); +console.log('The value of (16 % 6 ) is: ' + 16 % 6); +console.log('The value of (29 % 10) is: ' + 29 % 10); + +//10.More javascript +var array = ['HackYourFuture', 80 , "FooCafe", 199.95] +console.log(array); +console.log(typeof(7/0)); +console.log((7/0) === (6/0)); diff --git a/Week2/.DS_Store b/Week2/.DS_Store new file mode 100644 index 000000000..1ec21d4b5 Binary files /dev/null and b/Week2/.DS_Store differ diff --git a/Week2/Homework/More_JavaScript.js b/Week2/Homework/More_JavaScript.js new file mode 100644 index 000000000..05713cf44 --- /dev/null +++ b/Week2/Homework/More_JavaScript.js @@ -0,0 +1,176 @@ +//https://github.com/HackYourFuture/JavaScript1/blob/master/Week3/MAKEME.md + +//1 +function sum(a, b, c){ + let sumArguments = a + b + c; + console.log(sumArguments); +} + +sum(4,6,8); + + +//2 +function colorCar (Color) { + console.log("my car is " + Color); +} + +colorCar("red"); + + +//3 +const itsMe = { + firstname: "Melody", + lastname: "Vesal", + age: 28, + height: 165, +} + +function printMe(object){ + console.log(object); +} + +printMe(itsMe); + +//4 +function vehicleType(color,code){ + if (code==1){ + console.log('A ' + color + ' car.'); + } else if (code==2){ + console.log('A ' + color + ' motorbike.'); + } +} +vehicleType('white',1); + + +//5 +(3 === 3) ? console.log("yes") : console.log("no"); + + +//6 +function vehicle (color,code,age){ + if (code==1){ + if(age > 3) { + console.log('a ' + color + ' used car') + } else if( age>0 && age<3) { + console.log('a ' + color + ' new car') + } + } else if (code==2){ + if(age > 3) { + console.log('a ' + color + ' used motorbike') + } else if( age>0 && age<3) { + console.log('a ' + color + ' new motorbike') + } + } +} + +vehicle("blue", 1, 5); +vehicle("black", 2, 2); + + +//7 +let vehiclesList = ["motorbike", "caravan", "bike", "car", "bus"]; + + +//8 +console.log(vehiclesList[2]); + + +//9(*) +function vehicle(color,code,age){ +for(i = 0; i<=vehiclesList.length; i++){ +if (code==i){ + if(age > 3) { + console.log('a ' + color + ' used' + vehiclesList[i]) + } else if( age>0 && age<3) { + console.log('a ' + color + ' new' + vehiclesList[i]) + } +} +} +} + + vehicle("green", 3, 1); + + + //10(*) + let vehiclesList = ["motorbike", "caravan", "bike", "car", "bus"]; + function vehiclee(){ + let advertisement = "Amazing Joe's Garage, we service "; + for (i = 0; i < vehiclesList.length; i++) { + if (i == vehiclesList.length - 1) { + advertisement += "and " + vehiclesList[i] + "s."; + } else { + advertisement += vehiclesList[i] + "s, "; + } + } + return advertisement; + } + vehiclee(); + + +//11 +vehiclesList.push("truck"); +console.log(vehiclee()); + + +//12 +let myObject = {}; + + +//13 +let teacherObj = { + teachers : ["tomy" ,"rasmus", "mike", "viktor"], +} +console.log(teacherObj); + + +//14 +teacherObj.languages = ["HTML", "CSS", "Javascript"]; +console.log(teacherObj); + + +//15 +let x = [1,2,3]; +let y = [1,2,3]; +let z = y; +x == y ? console.log("they are equal") : console.log("they are not equal!"); //tehy are not equal +x === y ? console.log("they are equal") : console.log("they are not equal!");//tehy are not equal +z == x ? console.log("they are equal") : console.log("they are not equal!");//tehy are not equal +z === x ? console.log("they are equal") : console.log("they are not equal!");//tehy are not equal +z == y ? console.log("they are equal") : console.log("they are not equal!");//tehy are equal +z === y ? console.log("they are equal") : console.log("they are not equal!");//tehy are equal + + +//16 +let o1 = { foo: 'bar' }; +let o2 = { foo: 'bar' }; +let o3 = o2; + +console.log(o1); +console.log(o2); +console.log(o3); + +o1.foo = "black" +console.log(o1); +console.log(o2); //changing o1 will not change o2 +console.log(o3); //changing o1 will not change o3 +console.log("changing o1 will not change o3"); +console.log("changing o1 will not change o2"); + +o2.foo = "white" +console.log(o1); //changing o2 will not change o1 +console.log(o2); +console.log(o3); //changing o2 will change o3 +console.log("changing o2 will change o3"); + +o3.foo = "pink"; +console.log(o1); //changing o3 will not change o1 +console.log(o2); //changing o3 will not change o2 +console.log(o3); +console.log("changing o3 will change 02"); + + +//17 +let bar = 42; +console.log (typeof typeof bar); // using 2 typeof, will print string +console.log (typeof bar); // using 1 typeof, will print number + diff --git a/Week2/Homework/String_Array.js b/Week2/Homework/String_Array.js new file mode 100644 index 000000000..a0a109d0a --- /dev/null +++ b/Week2/Homework/String_Array.js @@ -0,0 +1,27 @@ +//javascript week2 + +//String +let myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log(myString); +console.log(myString.length); +let myNewString=myString.replace(/,/g," "); +console.log(myNewString); + +//Array + favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; +console.log(favoriteAnimals); +favoriteAnimals.push('turtle'); +console.log(favoriteAnimals); +favoriteAnimals.splice(1,0,'meerkat'); +console.log(' I think the new value of the array is between blowfish and capricon.'); +console.log(favoriteAnimals); +console.log('Array has the length of: ' + favoriteAnimals.length); +favoriteAnimals.splice(3,1); +console.log(favoriteAnimals); +var faIndex=favoriteAnimals.indexOf('meerkat'); +console.log('The item you are looking for is at Index: ' + faIndex); +favoriteAnimals.splice(faIndex,1); +console.log(favoriteAnimals); + + + diff --git a/Week3/.DS_Store b/Week3/.DS_Store new file mode 100644 index 000000000..41fa1cafc Binary files /dev/null and b/Week3/.DS_Store differ diff --git a/Week3/homework/app.js b/Week3/homework/app.js new file mode 100644 index 000000000..c294ac8d1 --- /dev/null +++ b/Week3/homework/app.js @@ -0,0 +1,163 @@ + +let myFavoritBooks = +["the_alchemist",//Paulo Coelho +"forty_rules_of_love",//Elif Shafak +"journey_to_a_better_you",//Joel Osteen +"eat_that_frog",//Brian Tracy +"by_the_river_piedra_i_sat_down_and_wept",//Paulo Coelho +"the_power_of_i_am",//Joel Osteen +"the_secret",//Rhonda Byrne +"one_hundred_years_of_solitude",//Gabriel Garcia Marquez +"the_right_questiones",//Debbie Ford +"someone_i_loved"//Anna Gavalda +]; + +// console.log(myFavoritBooks); + + +//write books id on HTML from an array +function createUl(arr){ + let ul = document.createElement('ul'); + ul.setAttribute('id', 'myFavoritBooks'); + document.body.appendChild(ul) + for (let i=0; i + + + Books list + + + +

JavaScript Week3 - DOM

+ Link to assignment source +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/Week3/homework/main.css b/Week3/homework/main.css new file mode 100644 index 000000000..14874fe22 --- /dev/null +++ b/Week3/homework/main.css @@ -0,0 +1,44 @@ +html{ + background-color:lightblue; + background-image: url(https://pre00.deviantart.net/c69b/th/pre/i/2010/071/b/2/bookcase_by_jcallius.jpg); + margin: 2px; + box-sizing:border-box; + display: block; +} +ul{ +background-color: beige; +padding: 30px 40px 40px 40px; +margin-right: 500px; +margin-left: 10px; +list-style-type: none; +} +a{ + background-color: beige; + color:black; + text-align-last: center; + padding: 10px 10px 10px 10px; + margin: 40px 10px 10px 10px; +} +h1{ + color: darkred; + background-color: beige; + margin:50px 50px 50px 50px; + text-align-last: center; + font-size: 30px; + font-family: fantasy; +} + +h2 { + font-family: Tahoma, sans-serif; + font-size: 16px; + color:white; + background-color: orangered; + margin:0px 400px 20px 10px; +} + +img { + width: 300px; + height: 350px; + border: 3px solid darkred; +} +