diff --git a/functions/sum/exercise/script.js b/functions/sum/exercise/script.js index 69d6b48..5c4b6c3 100644 --- a/functions/sum/exercise/script.js +++ b/functions/sum/exercise/script.js @@ -8,23 +8,49 @@ ES6 Syntax (Arrow function): const add = () => {} */ -function add(){ - //Add function here + +// function add(a, b){ +// //Add function here +// return a + b +// } + + +// let result1 = add(6, 7) +// console.log(result1) + +const sum = (a, b) =>{ +return a + b } +// console.log(sum(10, 50)) + -function sub(){ +function sub(a , b){ //Subtract function here + return a - b } +let result2 = sub(7, 6) +// console.log(result2) -function div(){ +function div(a,b){ //Divide function here + return(a / b) } +let result3 = div(20 , 2) +// console.log(result3) + +// function mul(a ,b){ +// //Multiply function here +// return(a * b) +// } +// let result4 = mul(20 , 2) +// console.log(result4) -function mul(){ - //Multiply function here -} console.log('hello from the SUM exercise') /* TODO: create a function that console logs the result of any of the above operations. -*/ \ No newline at end of file +*/ + + + + diff --git a/functions/sum/solution/script.js b/functions/sum/solution/script.js index 6a567a7..1593017 100644 --- a/functions/sum/solution/script.js +++ b/functions/sum/solution/script.js @@ -1 +1 @@ -console.log("Sum solution")) \ No newline at end of file +console.log("Sum solution") \ No newline at end of file diff --git a/yourPlayground.js b/yourPlayground.js index e69de29..9120b06 100644 --- a/yourPlayground.js +++ b/yourPlayground.js @@ -0,0 +1,51 @@ + +// Math Methods +//Floor ()- Rounds down +//Ceil() - Rounds up +//random() - Gives a random number + +let number = Math.floor(Math.random() * 4) + +console.log(number) + +const groceries = ['banana', 'orange', 'cucumber', 'kiwi', 'pear'] + +groceries.push('cookies') +groceries.push('chocolate') +console.log(groceries.indexOf('pear')) + console.log(groceries) + console.log(groceries[0]) + + //array slice +//start from 0 INCLUSIVE and up to 3 [0,3] + console.log(groceries.slice(0, 3)) +// console.log(groceries.splice(3, 6)) + console.log(groceries.splice(1, 3)) + +// Objects + +const personal = { + name: 'Lampard', + shirt: "black" +} + +console.log(personal.name) + + + +const introducerMe = (name, shirt) => { + const person = { + name: name, + shirt: shirt, + assets: 5000000, + liabilty : 100000, + netWorth : function (){ + return this.assets - this.liabilty + } +} + const intro = `Hi, my name is ${person.name} and the color of my shirt is ${person.shirt} and my net worth is $ ${person.netWorth()} USD` + + return intro +} + +console.log(introducerMe('Oyindamola', 'flowery')) \ No newline at end of file