diff --git a/HOME.html b/HOME.html new file mode 100644 index 0000000..35aaaa6 --- /dev/null +++ b/HOME.html @@ -0,0 +1,13 @@ + + + + Toy Problem + +
+ The Bio
+ + The Movies
+ + The Favorite
+ + \ No newline at end of file diff --git a/HigherFunctionsEach2.js b/HigherFunctionsEach2.js index f4f6764..4977e95 100644 --- a/HigherFunctionsEach2.js +++ b/HigherFunctionsEach2.js @@ -12,8 +12,14 @@ pName(x); = > ['Jon', 'Omar', 'salwa'] } function pName(argument) { - // your code is here - } + var allNames = {} + each(argument , function (argument,i) { + if(i %2 === 0 ){ + allNames[i] = argument["name"] + } + }) + return allNames ; +} /* @@ -44,5 +50,9 @@ printValue(obj_1); => function printValue(obj) { - // your code is here + var newArr = "" + each(obj , function (obj , key ) { + newArr += obj + "\n" + }) + return newArr } diff --git a/Movies.html b/Movies.html new file mode 100644 index 0000000..68f5345 --- /dev/null +++ b/Movies.html @@ -0,0 +1,20 @@ + + + + Movies + + +
    +
  1. Jordan
  2. +
  3. Canda
  4. +
  5. UAE
  6. + +
+ + + \ No newline at end of file diff --git a/Oop.js b/Oop.js new file mode 100644 index 0000000..4f91f26 --- /dev/null +++ b/Oop.js @@ -0,0 +1,38 @@ +// We have this code from Adding Methods With Closures lecture: +// Refactor the code as an MakeGame class that shares its methods across different instances. + + +function randInt(n) { + return Math.floor(Math.random() * (n + 1)); +} + +function makeGame(upperbound){ + + var game = {} + game.upperbound = upperbound + game.upper = upperbound; + game.rand = randInt(game.upper) + game.counter = 0; + + game.guessMyNumber = guessMyNumber ; + game.giveUp = giveUp ; + game.numOfGuesses = numOfGuesses ; + + return game +} + function guessMyNumber(n){ + this.counter++; + if (n > this.upper) { + return "Out of bounds! Please try a number between 0 and " + this.upperbound + "."; + } else if (n === this.rand) { + return "You guessed my number!"; + } + return "Nope! That wasn't it!"; + } + + function giveUp(){ + return this.rand; + } + function numOfGuesses(){ + return this.counter; + } \ No newline at end of file diff --git a/accum.js b/accum.js new file mode 100644 index 0000000..26bab02 --- /dev/null +++ b/accum.js @@ -0,0 +1,21 @@ +// This time no story, no theory. The examples below show you what do you need, write a function to accomplich that +// Examples: +// accum("abcd"); // "A-Bb-Ccc-Dddd" +// accum("RqaEzty"); // "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy" +// accum("cwAt"); // "C-Ww-Aaa-Tttt" + + function accum(input){ + //your code is here + var arr = input.split(""); + var str = "" + for (var i = 0; i < arr.length; i++) { + + str += arr[i].toUpperCase() ; + for (var j = 0; j < i; j++) { + str+=arr[i] + } + str+="-" + + } + return str + } \ No newline at end of file diff --git a/bio.html b/bio.html new file mode 100644 index 0000000..9cb440b --- /dev/null +++ b/bio.html @@ -0,0 +1,2 @@ +

Me i need to sleep (Zzzzz)

+

My pair was so cool , we had so match fun and solve the most of the questions

\ No newline at end of file diff --git a/closestMultipleOf10.js b/closestMultipleOf10.js new file mode 100644 index 0000000..c456e44 --- /dev/null +++ b/closestMultipleOf10.js @@ -0,0 +1,25 @@ + // Given a number return the closest number to it that is divisible by 10. + // Example : + // 22 ===> 20 + // 25 ===> 30 + // 37 ===> 40 + function closestMultipleOf10(num) { + //your code is here + var newNum = num%10 + var str = num +"" + if(newNum <=5){ + str = str[0] + "0" + str = parseInt(str ,"
") + return str + } + else{ + str = parseInt(str[0] ,"
") + + str +=1 + str+="" + str = str[0] + "0" + str = parseInt(str ,"
") + return str + } + + } \ No newline at end of file diff --git a/favorite.html b/favorite.html new file mode 100644 index 0000000..9684612 --- /dev/null +++ b/favorite.html @@ -0,0 +1,15 @@ + + + + + +

DeadPool

+ +

DarkSiders

+ +

Ezeo Al detori

+ +

The Flag

+ + + \ No newline at end of file diff --git a/htmlExample.js b/htmlExample.js new file mode 100644 index 0000000..64faad8 --- /dev/null +++ b/htmlExample.js @@ -0,0 +1,17 @@ +/* + 1) create HTML web-page HOME.html then set the title to Toy Problem + 2) create another web-page favorite.html then add your five favorite picture + 3) create web-page Movie.html that includes an order list for your favorite 3 countries and an unordered + list for your best five movies + 4) create web-page bio.html and add two paragraphs about you and your pair. + 5) if you finished the above, can you link these pages toghter? + + home.html + /|\ + / | favorite.html + / | + / Movie.html + / + bio.html + +*/ diff --git a/strings.js b/strings.js new file mode 100644 index 0000000..3356527 --- /dev/null +++ b/strings.js @@ -0,0 +1,26 @@ +// Write a function called characPosit, when provided with a letter, return its position in the alphabet. +// Input :: "a" +// Ouput :: "Position of alphabet: 1" + function characPosit(character){ + //your code is here + var newChar = character.toLowerCase(); + var arr = ["a" , "b" , "c" , "d" , "e" , "f" ,"g" , "h" , "i" , "j" , "k" , "l" , "m" , "n" ,"o" ,"p" , "q" , "r" , "s" , "t" , "v" , "w" , "x" , "y" , "z"] + + for (var i = 0; i < arr.length; i++) { + if(arr[i] === newChar){ + return i+1 + } + } + } + +// Write a function called repeatStr which repeats the given +// string string exactly n times. +// repeatStr("hello",4) ==> 'hellohellohellohello' + + function repeatStr(n, s) { + //your code is here + if (s === 0) { + return "" + } + return n + repeatStr(n,s-1) + } \ No newline at end of file diff --git a/strings2.js b/strings2.js new file mode 100644 index 0000000..70a0c54 --- /dev/null +++ b/strings2.js @@ -0,0 +1,24 @@ +// Given a sequence of items and a specific item in that sequence, return the item +// immediately following the item specified. If the item occurs more than once in a sequence, +// return the item after the first occurence. This should work for a sequence of any type. +// When the item isn't present or nothing follows it, the function should return null +// nextItem([1, 2, 3, 4, 5, 6, 7], 3) # 4 +// nextItem("testing", "t") # "e" + + function nextItem(items, elem){ + //your code is here + for (var i = 0; i < items.length; i++) { + if(items[i] === elem){ + return items[i+1] + } + } +} +// We need a function that can transform a number into a string. +// What ways of achieving this do you know? +// numberToString(123); // returns '123';` +// numberToString(999); // returns '999';` + + function numberToString(num) { + //your code is here + return num +"" + } \ No newline at end of file diff --git a/swap.js b/swap.js new file mode 100644 index 0000000..3bc3f1b --- /dev/null +++ b/swap.js @@ -0,0 +1,18 @@ + // Given a string, swap the case for each of the letters. + // IbrAHiM --> iBRahIm + // ToYPRoblEm --> tOyprOBLeM + function swap(input){ + //your code is here + var newstr = "" + for (var i = 0; i < input.length; i++) { + + if(input[i] === input[i].toLowerCase()){ + newstr+=input[i].toUpperCase() + } + else if(input[i] === input[i].toUpperCase()){ + newstr+=input[i].toLowerCase() + } + } + return newstr + + } \ No newline at end of file