From 8a3d324a6c91f6d16be59985db9fed76d4bb65d9 Mon Sep 17 00:00:00 2001 From: ranoualachheb Date: Fri, 13 Mar 2020 09:50:41 +0000 Subject: [PATCH 01/16] edited --- warmUp1.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/warmUp1.js b/warmUp1.js index 359b609..d7c31bb 100644 --- a/warmUp1.js +++ b/warmUp1.js @@ -1,6 +1,30 @@ // 1-using + operator combine your partner first and last name . +'lachheb'+ 'ranoua' // 2-find if the number 13 is a multiple of 3 or not. +function multiple(n) { + if (13/3 === 0) { + return '13 is multiple of 3' + } else{ + return '13 is not multiple of 3' + } + +} // 3-calculate the average age of the follwing ages [13,14,13,15,16,17,19,13,16,15] +function average (arr){ + var i = 0 + var result = 0 + var sum = arr.length ; + while (i Date: Sat, 14 Mar 2020 09:01:25 +0100 Subject: [PATCH 02/16] warmUp2 --- warmUp2.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 warmUp2.js diff --git a/warmUp2.js b/warmUp2.js new file mode 100644 index 0000000..a6d6932 --- /dev/null +++ b/warmUp2.js @@ -0,0 +1,26 @@ +// 1 - Complete the function cube that returns the cube of x: + +function cube(x) { + // your code here +} + +// 2 - Write a function sameLength that accepts two strings as arguments, and returns true if those strings have the same length, and false otherwise. + +function sameLength(string1, string2) { + // your code here +} + +// 3 - Write a function called scoreToGrade that accepts a number as a parameter and returns a string representing a letter grade corresponding to that score. + +function scoreToGrade(number) { + // your code here +} +// Repeating a String n Times: Let's write a function called repeatString that takes two parameters: a string str, which is the string to be repeated, and count -- a number representing how many times the string str should be repeated +// repeatString('dog', 0); // => '' +// repeatString('dog', 1); // => 'dog' +// repeatString('dog', 2); // => 'dog' + 'dog' => 'dogdog' +// repeatString('dog', 3); // => 'dog' + 'dog' + 'dog' => 'dogdogdog' + +function repeatString(str, count) { + // TODO: your code here +} From b6d9181a5da11874e4d98f4d0f2d685b4e6a64f9 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Sat, 14 Mar 2020 09:06:23 +0100 Subject: [PATCH 03/16] updated --- warmUp2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/warmUp2.js b/warmUp2.js index a6d6932..42f5983 100644 --- a/warmUp2.js +++ b/warmUp2.js @@ -15,6 +15,7 @@ function sameLength(string1, string2) { function scoreToGrade(number) { // your code here } +// USE RECURSION // Repeating a String n Times: Let's write a function called repeatString that takes two parameters: a string str, which is the string to be repeated, and count -- a number representing how many times the string str should be repeated // repeatString('dog', 0); // => '' // repeatString('dog', 1); // => 'dog' From eb96a4926f1c48f37660c1aa04e7b0ff70061feb Mon Sep 17 00:00:00 2001 From: ranoualachheb Date: Sat, 14 Mar 2020 10:22:30 +0100 Subject: [PATCH 04/16] modification done --- warmUp2.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/warmUp2.js b/warmUp2.js index 42f5983..eadcf07 100644 --- a/warmUp2.js +++ b/warmUp2.js @@ -1,18 +1,28 @@ // 1 - Complete the function cube that returns the cube of x: function cube(x) { + return x*x*x ; // your code here } // 2 - Write a function sameLength that accepts two strings as arguments, and returns true if those strings have the same length, and false otherwise. - -function sameLength(string1, string2) { - // your code here +function sameLength(str1,str2){ + if (str1.length === str2.length){ + return true ; + } + return false ; } // 3 - Write a function called scoreToGrade that accepts a number as a parameter and returns a string representing a letter grade corresponding to that score. function scoreToGrade(number) { + if (number === 0 ) { + return 'F'; + } else if (number < 60 ){ + return 'B' ; + } else { + return 'A' ; + } // your code here } // USE RECURSION @@ -22,6 +32,11 @@ function scoreToGrade(number) { // repeatString('dog', 2); // => 'dog' + 'dog' => 'dogdog' // repeatString('dog', 3); // => 'dog' + 'dog' + 'dog' => 'dogdogdog' -function repeatString(str, count) { +function repeatString(str, count) { + var string = '' + if ( count === 0){ + return string ; + } + return string = str + repeatString(str, count-1) // TODO: your code here } From 87d1ed2d16e10c1a29cf07bf66d1b516783bcf2c Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Mon, 16 Mar 2020 09:11:19 +0100 Subject: [PATCH 05/16] warmUp3 is pushed --- warmUp3.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 warmUp3.js diff --git a/warmUp3.js b/warmUp3.js new file mode 100644 index 0000000..ae817da --- /dev/null +++ b/warmUp3.js @@ -0,0 +1,21 @@ +// 1 - Write functions larger and smaller that each accept two strings as arguments, and return the larger and smaller strings, respectively + +// 2 - Write a function called counter that, when invoked, always returns a number that is one more than the previous invocation. For instance: +// function counting(n) { + TODO: your code here +// } +// counting(5); // => '1, 2, 3, 4, 5' +// counting(1); // => '1' +// counting(3); // => '1, 2, 3' + + +// 3 - Meet & Greet: n numbers are coming to a party for numbers. Introduce them each to all the guests as they arrive. You should end up with output looking something like this one for n = 5 +// welcome 1 +// welcome 2, meet 1 +// welcome 3, meet 1 and 2 +// welcome 4, meet 1, 2 and 3 +// welcome 5, meet 1, 2, 3 and 4 +// + +// 4- Write a function shortestWord that works like longestWord, but returns the shortest word instead. + From 39d883a3be3b607b388ed25e0c7dbf45e1b0fdc1 Mon Sep 17 00:00:00 2001 From: ranoualachheb Date: Mon, 16 Mar 2020 09:52:50 +0100 Subject: [PATCH 06/16] solved --- warmUp3.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/warmUp3.js b/warmUp3.js index ae817da..95818e1 100644 --- a/warmUp3.js +++ b/warmUp3.js @@ -1,8 +1,14 @@ // 1 - Write functions larger and smaller that each accept two strings as arguments, and return the larger and smaller strings, respectively - +function larsma(str1,str2){ +if (str1.length> str2.length){ + return str1 + ' '+ str2 +} +} // 2 - Write a function called counter that, when invoked, always returns a number that is one more than the previous invocation. For instance: // function counting(n) { - TODO: your code here + function counter(n){ + return n+1 + } // } // counting(5); // => '1, 2, 3, 4, 5' // counting(1); // => '1' @@ -10,6 +16,8 @@ // 3 - Meet & Greet: n numbers are coming to a party for numbers. Introduce them each to all the guests as they arrive. You should end up with output looking something like this one for n = 5 +i saw the solution for this exercice and i still didnt get it.. sorry :p + // welcome 1 // welcome 2, meet 1 // welcome 3, meet 1 and 2 @@ -18,4 +26,11 @@ // // 4- Write a function shortestWord that works like longestWord, but returns the shortest word instead. +function shortestword(str,str1){ + var total = '' + if (str.length < str1.length){ + total = total + str + } + return total ; +} From 4ab3967cd0764bea1a7614a1d87ac2da4d6ea391 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Mon, 16 Mar 2020 21:19:14 +0100 Subject: [PATCH 07/16] warmUp 4 --- warmUp3.js | 12 +++++------- warmUp4.js | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 warmUp4.js diff --git a/warmUp3.js b/warmUp3.js index ae817da..9e5778b 100644 --- a/warmUp3.js +++ b/warmUp3.js @@ -1,14 +1,13 @@ // 1 - Write functions larger and smaller that each accept two strings as arguments, and return the larger and smaller strings, respectively // 2 - Write a function called counter that, when invoked, always returns a number that is one more than the previous invocation. For instance: -// function counting(n) { - TODO: your code here -// } -// counting(5); // => '1, 2, 3, 4, 5' -// counting(1); // => '1' +// function counting(n) { +// TODO: your code here +// } +// counting(5); // => '1, 2, 3, 4, 5' +// counting(1); // => '1' // counting(3); // => '1, 2, 3' - // 3 - Meet & Greet: n numbers are coming to a party for numbers. Introduce them each to all the guests as they arrive. You should end up with output looking something like this one for n = 5 // welcome 1 // welcome 2, meet 1 @@ -18,4 +17,3 @@ // // 4- Write a function shortestWord that works like longestWord, but returns the shortest word instead. - diff --git a/warmUp4.js b/warmUp4.js new file mode 100644 index 0000000..6db784a --- /dev/null +++ b/warmUp4.js @@ -0,0 +1,8 @@ +// 1-write a function that returns the product of any number by 3. + +// 2-complete the following function multiply to return the result of multiplying of x and y + +// 3-complete the following function that Convert Fahrenheit to Celsius if the module for converting is +// (5/9) * (fahrenheit-32); + +// 4-Define a function named "sqArea", and make it display square area if you knew the length of its side. From b0ec828ea6e15714eee5fd8dde21f06ed724a9b3 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Wed, 18 Mar 2020 09:01:34 +0100 Subject: [PATCH 08/16] warmUp5 --- warmUp5.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 warmUp5.js diff --git a/warmUp5.js b/warmUp5.js new file mode 100644 index 0000000..1313865 --- /dev/null +++ b/warmUp5.js @@ -0,0 +1,43 @@ +// 1) Write a function named greaterNum that: +// - takes 2 arguments, both numbers. +// - returns whichever number is the greater (higher) number. +// ex greaterNum(5, 10) => "The greater number of 5 and 10 is 10." + +// 2) Write a function named isEven using for loop that +// - iterate from x to y. +// - return array contain the even values, +// ex: isEven(1,10) => [2,4,6,8,10] + +// function isEven(x, y) { +// var arr = []; +// for (var i = 0; i < arr.length; i++) { +// while (x <= y) { +// if (x % 2 === 0) { +// arr[i] = arr.push(x) +// } +// x++ +// } +// } +// return arr; +// } +//3) write a function named sum that +// - Use a while loop to add up the numbers from x to y. +// ex sum(1,5) => 15 + +//4) Write a function named factorial that +// - Use Recursion to calculate the factorial of a number +// - the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n +// - 5! = 5*4*3*2*1 = 120 +// ex : factorial(5) => 120 + +//5) write a function named decimals +//- the function will format a number up to specified decimal places +//- the function will return a string +//- if the parameters not a number return false +// ex : +// decimals(2100, 'a') ==> false +// decimals('a', 5) ==> false +// decimals(2.100212, 2) ==> '2.10' +// decimals(2.100212, 3) ==> '2.100' +// decimals(2100, 2) ==> '2100.00' +// From bb8f600beae6ba6bb118e46f212284106e2681e3 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Wed, 18 Mar 2020 09:09:58 +0100 Subject: [PATCH 09/16] warmup5 --- warmUp5.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/warmUp5.js b/warmUp5.js index 1313865..0c715fa 100644 --- a/warmUp5.js +++ b/warmUp5.js @@ -9,16 +9,7 @@ // ex: isEven(1,10) => [2,4,6,8,10] // function isEven(x, y) { -// var arr = []; -// for (var i = 0; i < arr.length; i++) { -// while (x <= y) { -// if (x % 2 === 0) { -// arr[i] = arr.push(x) -// } -// x++ -// } -// } -// return arr; + // } //3) write a function named sum that // - Use a while loop to add up the numbers from x to y. From a293eee4d2c674c5243436c035f584a16e547e59 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Thu, 19 Mar 2020 00:55:23 +0100 Subject: [PATCH 10/16] warmUp6 --- warmUp6.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 warmUp6.js diff --git a/warmUp6.js b/warmUp6.js new file mode 100644 index 0000000..7d74294 --- /dev/null +++ b/warmUp6.js @@ -0,0 +1,10 @@ +// Style your code and explain it step by step before jumping to code :D +// Read carefully, focus and test your code :) ... /\ HaPPy HaCkInG /\ + +// 1-Define a function called myTrueFun that returns true whenever its called. + +// 2- Define a function called color in which returns true if type of the input is string and returns false otherwise. + +// 3-Write a JavaScript function that accepts a number as a parameter and check if the number is prime or not. + +// 4-write a function that accepts two numbers as parameters and returns true if the two parameters have the same value , false if not From 73e04b61657408c6ea6a9ab4a14d709b94015fe9 Mon Sep 17 00:00:00 2001 From: ranoua lachheb Date: Thu, 19 Mar 2020 09:59:43 +0100 Subject: [PATCH 11/16] good warm up --- warmUp6.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/warmUp6.js b/warmUp6.js index 7d74294..0f93ece 100644 --- a/warmUp6.js +++ b/warmUp6.js @@ -2,9 +2,31 @@ // Read carefully, focus and test your code :) ... /\ HaPPy HaCkInG /\ // 1-Define a function called myTrueFun that returns true whenever its called. +function myTrueFun(){ + return true ; +} // 2- Define a function called color in which returns true if type of the input is string and returns false otherwise. +function color(str){ + +} // 3-Write a JavaScript function that accepts a number as a parameter and check if the number is prime or not. +function javascript(n){ + if (n === 0 || n === 1){ + return "not a prime number" + } else if (n % 2 === 0 ) { + return "a prime number"; + } else { + return "not a prime number" + } +} // 4-write a function that accepts two numbers as parameters and returns true if the two parameters have the same value , false if not +function js (a,b){ + if (a === b){ + return true + } else { + return false + } +} \ No newline at end of file From 49a776a2a1b330f827e34aaee70c22749e95e924 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Thu, 19 Mar 2020 23:21:28 +0100 Subject: [PATCH 12/16] warmUp7 --- warmUp7.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 warmUp7.js diff --git a/warmUp7.js b/warmUp7.js new file mode 100644 index 0000000..bb45934 --- /dev/null +++ b/warmUp7.js @@ -0,0 +1,12 @@ +// 1-Choose the correct comparison operator to display "true", when: 5 is less than 7. +//answer : + +//2- Write a function named helloWorld that: +//takes 1 argument, a language code (e.g. "fr", "es", "en") +//returns "Hello, World" for the given language, for atleast 3 languages. It should default to returning English. +//ex: helloWorld('fr') ==> 'Bonjour tout le monde' +// helloWorld('es') ==> 'Hola, Mundo' +// helloWorld('') ==> 'Hello, World' + +//3- write a function to Reverse an array without use array.reverse() method: +// ex: reverseArray([1,2,3]) ==> [3,2,1] From fe5821921c1b978676ee341fefa42d94af6e0768 Mon Sep 17 00:00:00 2001 From: ranoua lachheb Date: Fri, 20 Mar 2020 10:58:26 +0100 Subject: [PATCH 13/16] done it --- warmUp7.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/warmUp7.js b/warmUp7.js index bb45934..c361234 100644 --- a/warmUp7.js +++ b/warmUp7.js @@ -1,12 +1,41 @@ // 1-Choose the correct comparison operator to display "true", when: 5 is less than 7. //answer : - +function comparison(a,b){ + if ((a===5) && (b===7)){ + return a 'Bonjour tout le monde' // helloWorld('es') ==> 'Hola, Mundo' // helloWorld('') ==> 'Hello, World' +function helloWorld(str){ + var result = ""; + switch(str) { + case "fr": + result = "bonjour tout le monde"; + break; + case "esp": + result = "hola mundo"; + break; + default: + result= "hello world"; + break; + + } + return result; +} //3- write a function to Reverse an array without use array.reverse() method: // ex: reverseArray([1,2,3]) ==> [3,2,1] +function reverse(array){ + var arr=[] + var i = 0 ; + while( i < array.length ) { + arr.unshift(array[i]) + i++; + } + return arr; +} \ No newline at end of file From 69e466b56ec53a012dc13b819bebda0ed79bed29 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Sat, 21 Mar 2020 01:55:56 +0100 Subject: [PATCH 14/16] warmUp 8 --- warmUp8.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 warmUp8.js diff --git a/warmUp8.js b/warmUp8.js new file mode 100644 index 0000000..11e4be0 --- /dev/null +++ b/warmUp8.js @@ -0,0 +1,8 @@ +// 1 - Write a function named objKey that take an object as a parameter and returns an array containing the keys of the object +// objKey({name:'ahmed',age:20}) ==> ['name','age'] + +// 2 - Write a function named objLength to get the length of a JavaScript object +// objLength({name:'ahmed',age:20}) ==> 2 + +// 3 - Write a function named objSort to sort an array of JavaScript objects based on the id +// objSort([{id:2,value:50},{id:0,value:70},{id:1,value:40}]) ==> [{id:0,value:70},{id:1,value:40},{id:2,value:50}] From 688273ddf9484c898f62671ccf713b776d583b29 Mon Sep 17 00:00:00 2001 From: Seif-Miehiar Date: Mon, 23 Mar 2020 00:01:03 +0100 Subject: [PATCH 15/16] warmUp 9 --- warmUp9.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 warmUp9.js diff --git a/warmUp9.js b/warmUp9.js new file mode 100644 index 0000000..b05ef52 --- /dev/null +++ b/warmUp9.js @@ -0,0 +1,34 @@ +// Style your code and explain it step by step before jumping to code :D +// Read carefully, focus and test your code :) ... /\ HaPPy HaCkInG /\ + +//1. Write a JavaScript function to check whether an `input` is an array or not +// ex isArray([1,2])=>true +// isArray(5)=>false + +// **************** git status **************** +// **************** git add fileName.js **************** +// **************** git status **************** +// **************** git commit -m "your message" **************** +// **************** git status **************** +// **************** git push origin master **************** + +//2-Write a JavaScript function to get the first n element of an array. +//ex first([1,2,3],1)=>[1] +// first([1,2,3,4]2)=>[1,2] + +// **************** git status **************** +// **************** git add fileName.js **************** +// **************** git status **************** +// **************** git commit -m "your message" **************** +// **************** git status **************** +// **************** git push origin master **************** + +//3- Write a JavaScript function to convert an object into a list of `[key, value]` pairs +//ex: convert({name:'ahmed',age:20})=>[['name','ahmed'],['age', 20]] + +// **************** git status **************** +// **************** git add fileName.js **************** +// **************** git status **************** +// **************** git commit -m "your message" **************** +// **************** git status **************** +// **************** git push origin master **************** From 540a244d58cbba40aa1f08daa3a5e7fea9b2ca43 Mon Sep 17 00:00:00 2001 From: ranoua lachheb Date: Mon, 23 Mar 2020 10:46:54 +0100 Subject: [PATCH 16/16] warm up 9 done --- warmUp9.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/warmUp9.js b/warmUp9.js index b05ef52..40e0822 100644 --- a/warmUp9.js +++ b/warmUp9.js @@ -4,6 +4,12 @@ //1. Write a JavaScript function to check whether an `input` is an array or not // ex isArray([1,2])=>true // isArray(5)=>false +// i found this function in mdn +function isArray(arr){ + return array.isArray(arr) +} + + // **************** git status **************** // **************** git add fileName.js **************** @@ -15,6 +21,14 @@ //2-Write a JavaScript function to get the first n element of an array. //ex first([1,2,3],1)=>[1] // first([1,2,3,4]2)=>[1,2] +// SO i put i[['name','ahmed'],['age', 20]] +function javascript(obj){ +} // **************** git status **************** // **************** git add fileName.js **************** // **************** git status **************** // **************** git commit -m "your message" **************** // **************** git status **************** // **************** git push origin master **************** + + + +// i can do this i just need more time \ No newline at end of file