Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warmupDone #41

Open
wants to merge 58 commits into
base: bessam-haj-salem
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7fa95f0
i finish
bessam-haj-salem Mar 13, 2020
0ae6b18
just practicing
bessam-haj-salem Mar 13, 2020
f52290e
practice
bessam-haj-salem Mar 13, 2020
9a3bc1a
warmUp2
Seif-Miehiar Mar 14, 2020
b6d9181
updated
Seif-Miehiar Mar 14, 2020
b068de2
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
bessam-haj-salem Mar 14, 2020
fd3b7b2
exercices resolved
bessam-haj-salem Mar 14, 2020
87d1ed2
warmUp3 is pushed
Seif-Miehiar Mar 16, 2020
da728c4
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
bessam-haj-salem Mar 16, 2020
e028fa4
work done
bessam-haj-salem Mar 16, 2020
4ab3967
warmUp 4
Seif-Miehiar Mar 16, 2020
c6d6b4c
work done a long time ago
Mar 17, 2020
b0ec828
warmUp5
Seif-Miehiar Mar 18, 2020
bb8f600
warmup5
Seif-Miehiar Mar 18, 2020
13c9090
work almost done
Mar 18, 2020
7e2c034
warmUp 5✔
Hashem-Buzer Mar 18, 2020
a293eee
warmUp6
Seif-Miehiar Mar 18, 2020
0b43f5b
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 19, 2020
8b5ecdb
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Hashem-Buzer Mar 19, 2020
a194561
work done
Mar 19, 2020
49a776a
warmUp7
Seif-Miehiar Mar 19, 2020
a426c68
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 20, 2020
acd035b
work done
Mar 20, 2020
83d2003
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Hashem-Buzer Mar 20, 2020
33c87b6
solved
Hashem-Buzer Mar 20, 2020
e30243f
warmUp7 is solved
Hashem-Buzer Mar 20, 2020
69e466b
warmUp 8
Seif-Miehiar Mar 21, 2020
ae477b2
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 21, 2020
11f895e
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Hashem-Buzer Mar 21, 2020
5094871
work done for saturday
Mar 21, 2020
943001a
warmUp8 ✔
Hashem-Buzer Mar 21, 2020
688273d
warmUp 9
Seif-Miehiar Mar 22, 2020
ea1fc58
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 23, 2020
6c83c81
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Hashem-Buzer Mar 23, 2020
6eeb89c
work done
Mar 23, 2020
a681610
warmUp9 ✔
Hashem-Buzer Mar 23, 2020
0e47aea
warmUp 10
Seif-Miehiar Mar 23, 2020
358b4b4
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 24, 2020
22f018c
work done
Mar 24, 2020
fc39922
i forgot something in the last function
Mar 24, 2020
651ca42
test the pull request
Hashem-Buzer Mar 24, 2020
2e45991
warmUp11
Hashem-Buzer Mar 25, 2020
e462924
Update warmUp5.js
Houda-Rouaissi Mar 25, 2020
1e0ee78
Update warmUp8.js
Houda-Rouaissi Mar 25, 2020
542e878
Update warmUp4.js
Houda-Rouaissi Mar 25, 2020
aeafcae
Update warmUp7.js
Houda-Rouaissi Mar 25, 2020
653380f
Update warmUp9.js
Houda-Rouaissi Mar 25, 2020
eedf4d1
warmUp 6
Houda-Rouaissi Mar 25, 2020
ad15f91
work reallt done
Mar 25, 2020
61b0662
warmUp12
mohamed-Dhia Mar 26, 2020
89efd90
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 26, 2020
fa1d619
work done
Mar 26, 2020
344f789
warmUp 13
Seif-Miehiar Mar 27, 2020
6cea703
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 27, 2020
e34770d
work done
Mar 27, 2020
f7116e6
warmUp 14
Seif-Miehiar Mar 28, 2020
302ede6
Merge branch 'master' of https://github.com/RBK-RebootKampTunisiaCoho…
Mar 28, 2020
a9fc92f
work done perfectly
Mar 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
29 changes: 29 additions & 0 deletions warmUp1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,32 @@
// 4-calculate your age in seconds.

// your code is here

function combine(firstname,lastname){
return firstname + ' ' + lastname;
}

function multiple(n){
if(n % 3 === 0){
return 'this number is a multiple of 3';
return 'this is not a multiple of 3';
}
}
function average(array){

var max = array[0];
for( i = 0 ; i < array.length ; i++){
if (max < arr[i]){
max = arr[i];
}

return max;

}

}

function age(n){
return n * 365 * 24 * 60 * 60;
}

43 changes: 43 additions & 0 deletions warmUp10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Style your code and explain it step by step before jumping to code :D
// Read carefully, focus and test your code :) ... /\ HaPPy HaCkInG /\

// **************** git status ****************
// **************** git add fileName.js ****************
// **************** git status ****************
// **************** git commit -m "your message" ****************
// **************** git status ****************
// **************** git push origin master ****************

// 1- Using recursion Write a JavaScript program to find the greatest common divisor (gcd) of two positive numbers.
function gcd(a, b){
if(a===b){
return a; // this is our stop condition
}
else if (a > b){
return gcd(a - b, b); // the function will call it self and decrement the value of a untill it reach 0 and return to the stop condition
}
else return gcd(a, b - a); // same thing here but b > a
}

// **************** git status ****************
// **************** git add fileName.js ****************
// **************** git status ****************
// **************** git commit -m "your message" ****************
// **************** git status ****************
// **************** git push origin master ****************

// 2-Write a function called sum that accepts two numbers as parameters, and sum them together but without suming them togther directly
//you can only add one at each summetion, you'll need to use recursion in this.

function sum(a, b){
if(a === 0){
return b; // this is the stop condition in this case that the sum of 0 and b is b
}
else return sum(a - 1, b + 1); // this function will call itself untill a is equal to 0 and return to the stop condition
}
// **************** git status ****************
// **************** git add fileName.js ****************
// **************** git status ****************
// **************** git commit -m "your message" ****************
// **************** git status ****************
// **************** git push origin master ****************
23 changes: 23 additions & 0 deletions warmUp11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 1-Create arrays in the global scope consisting of strings that represent:
// -name of females in your class
// -name of males in your class
// -name of your class instructors

var namesClass = [ {
names of females : [Ranoua, wala, Emna, Reem, Amal],
names of males : [Ahamed, Hamza, Brahim, youssef],
names of instructors : [dhia, farouk, jihed, houda, insaf, hachem]
}
];
// 2-write a function that takes an array as an argument and returns the element that is located in the middle of that array.
var arr1 = [];
function locMiddle(arr){

if( arr.length % 2 !== 0){
return arr[(arr.length - 1)/2];
}
else return arr1.push(arr[(arr.length/2) - 1], arr[(arr.length/2)]);
}

// 3-Change all the numbers in the array to be multiplied by two for even indexes.
const changeArray =(arr) => arr.map(x => x * 2);
33 changes: 33 additions & 0 deletions warmUp12.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 1-Write a function that takes a string as an input and returns the reverse of each letter
//followed by a number starting from zero(solve it using while loop).
// example: reverseStr('hello'); "o0l1l2e3h4"
function reverse(str){
var i = 1;
var j = str.length - 2;
var result = "";
var l = 1;
while(i < str.length) {
result = result + str.slice(j, -i) + l;
i++;
j--;
l++;
}
return str.slice(str.length - 1) + 0 + result;
}



// 2-write a function that takes array of strings and returns an array of the strings that have the same length
// example : ['hi','hello','welcome','hy'] == > ["hi","hy"]

function arrlength(arr){
var i = 0;
var arr1 = [];
while( i < arr.length){
if(arr[i].length === arr[i + 1].length){
arr1.push(arr[i],arr[i + 1])
}
i++;
}
return arr1;
}
31 changes: 31 additions & 0 deletions warmUp13.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Style your code and explain it step by step before jumping to code :D
// Read carefully, focus and test your code :) ... /\ HaPPy HaCkInG /\

// 1-implement the function mult that takes a single parameter n, and computes the multiplication of all integers up to n
//starting from 0, e.g.:
// mult(3); // => 6
// mult(4); // => 24
function mult(n){
var result = 1; // we can't begin with 0 because its a multiplication
for(var i = 0; i < n ; i++){
result = result * (n - i); // we increment i so we have each time n * (n - 1) * (n - 2) * ... * (n - (n -1))
}
return result;

}

// 2- Use a while loop to build a single string with the numbers 1 through n
// separated by the number next to the current number.
//Have it return the new string.
// eg= 1 2 2 3 3 4 4 5 5 6 6 ...
function repeat(n){
var result = ""; // we initialise the result by a string type so we have a string result
var i = 1;
var j = 1; // we begin with 1 for i and j so we can add the 1 after because we have 1 22 and not 11 22
while ( i < n && j < n ){
i++; // we need here two counters so we can have this repetition 11 22 etc
j++;
result = result + ' ' + i + ' ' + j;
}
return 1 + result; // here we add the 1
}
26 changes: 26 additions & 0 deletions warmUp14.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Style your code and explain it step by step before jumping to code :D
// Read carefully, focus and test your code :) ... /\ HaPPy HaCkInG /\

//create a function isSubset that should take two arrays and determine whether the second array is a subset of the first array.
//For example:

// array: [ 1, 2, 3, 4 ], sub:[ 2, 3, 4 ] => true
// array: [ 2, 2, 2, 3, 4 ], sub:[ 2, 4, 3 ] => true
// array: [ 2, 3, 3, "a" ], sub:[ 3, 3, 3, "a" ] => false

function isSubset(array1,array2){
var result = 0;
for(var i = 0; i < array1.length; i++){
for(var j = 0 ; j < array2.length; j++){ // we must do a counteur inside a counteur so he can scan first all the elements of array with one element of the subarray and splice it after
if(array1[i] === array2[j]){
result = true;
array2.splice(j,1); // splice and go to the next element

}
else result = false;
}
result;
}
return result;
}

73 changes: 73 additions & 0 deletions warmUp2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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) {
if (string1.length > string2.length){
return string1;}
return 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) {
if( n < 60){
return 'F'
};
else if (n > 60 && n < 62){
return 'D-'
};

else if (n > 63 && n < 66){
return 'D'
};
else if (n > 67 && n < 69){
return 'D+'
};
else if (n > 70 && n < 72){
return 'C-'
};
else if (n > 73 && n < 76){
return 'C'
};
else if (n > 77 && n < 79){
return 'C+'
};
else if (n > 80 && n < 82){
return 'B-'
};
else if (n > 83 && n < 86){
return 'B'
};
else if (n > 87 && n < 89){
return 'B+'
};
else if (n > 90 && n < 92){
return 'A-'
};
else return 'A'


}
// 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'
// repeatString('dog', 2); // => 'dog' + 'dog' => 'dogdog'
// repeatString('dog', 3); // => 'dog' + 'dog' + 'dog' => 'dogdogdog'

var result = '';
function repeatString(str, count) {
while(count > 0){

result = result + repeatString(str,count - 1);
count = count -1
}
return result;
}
44 changes: 44 additions & 0 deletions warmUp3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 1 - Write functions larger and smaller that each accept two strings as arguments, and return the larger and smaller strings, respectively
function largerAndSmaller(str1,str2){
if(str1>str2){
return "the smaller string is " + ' ' + str2;
}
return "the larger string is " + ' ' + str1;
}





// 2 - Write a function called counter that, when invoked, always returns a number that is one more than the previous invocation. For instance:
<<<<<<< HEAD
// function counting(n) {
var result1 = 0;
var result2 = 0;
counting(n){
result1 = n + 1;
result2 = result1 + 1
return result2;

}
// }
// 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'
>>>>>>> bb8f600beae6ba6bb118e46f212284106e2681e3
// 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.
32 changes: 32 additions & 0 deletions warmUp4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 1-write a function that returns the product of any number by 3.

<<<<<<< HEAD
function product(n){
return n * 3;
}

// 2-complete the following function multiply to return the result of multiplying of x and y

function multiply(x,y){
return x * y;
}

// 3-complete the following function that Convert Fahrenheit to Celsius if the module for converting is
// (5/9) * (fahrenheit-32);
function convert(n){
return (5/9) * (n - 32);
}

// 4-Define a function named "sqArea", and make it display square area if you knew the length of its side.
function sqArea(a,b){
return a * b;
}
// a and b are the length of the sides
=======
// 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.
>>>>>>> bb8f600beae6ba6bb118e46f212284106e2681e3
Loading