Skip to content

Commit 6c53301

Browse files
intro to array
1 parent 4388ee4 commit 6c53301

File tree

3 files changed

+59
-9
lines changed

3 files changed

+59
-9
lines changed

functions/sum/exercise/script.js

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,49 @@
88
ES6 Syntax (Arrow function): const add = () => {}
99
*/
1010

11-
function add(){
12-
//Add function here
11+
12+
// function add(a, b){
13+
// //Add function here
14+
// return a + b
15+
// }
16+
17+
18+
// let result1 = add(6, 7)
19+
// console.log(result1)
20+
21+
const sum = (a, b) =>{
22+
return a + b
1323
}
24+
// console.log(sum(10, 50))
25+
1426

15-
function sub(){
27+
function sub(a , b){
1628
//Subtract function here
29+
return a - b
1730
}
31+
let result2 = sub(7, 6)
32+
// console.log(result2)
1833

19-
function div(){
34+
function div(a,b){
2035
//Divide function here
36+
return(a / b)
2137
}
38+
let result3 = div(20 , 2)
39+
// console.log(result3)
40+
41+
// function mul(a ,b){
42+
// //Multiply function here
43+
// return(a * b)
44+
// }
45+
// let result4 = mul(20 , 2)
46+
// console.log(result4)
2247

23-
function mul(){
24-
//Multiply function here
25-
}
2648

2749
console.log('hello from the SUM exercise')
2850
/*
2951
TODO: create a function that console logs the result of any of the above operations.
30-
*/
52+
*/
53+
54+
55+
56+

functions/sum/solution/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.log("Sum solution"))
1+
console.log("Sum solution")

yourPlayground.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
console.log('hello world')
2+
3+
// Math Methods
4+
//Floor ()- Rounds down
5+
//Ceil() - Rounds up
6+
//random() - Gives a random number
7+
8+
let number = Math.floor(Math.random() * 4)
9+
10+
console.log(number)
11+
12+
const groceries = ['banana', 'orange', 'cucumber', 'kiwi', 'pear']
13+
14+
groceries.push('cookies')
15+
groceries.push('chocolate')
16+
console.log(groceries.indexOf('pear'))
17+
console.log(groceries)
18+
console.log(groceries[0])
19+
20+
//array slice
21+
//start from 0 INCLUSIVE and up to 3 [0,3]
22+
console.log(groceries.slice(0, 3))
23+
// console.log(groceries.splice(3, 6))
24+
console.log(groceries.splice(1, 3))

0 commit comments

Comments
 (0)