scrimba
JS Deep Dive
Functions
Challenge: Arrow Functions
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Challenge: Arrow Functions
AboutCommentsNotes
Challenge: Arrow Functions
Expand for more info
index.js
run
preview
console
// Challenge: Rewrite your first function from a previous challnge to be an arrow function. 
// Stretch goal: Rewrite counting down closure in arrow function form.


// Challenge start
function splitBill(amount, numPeople) {
return `Each person needs to pay ${amount / numPeople}`
}

// console.log(splitBill(10, 2));
// console.log(splitBill(10, 4));
// console.log(splitBill(10, 5));


// Stretch goal start
function countdown(startingNumber, step) {
let countFromNum = startingNumber + step;
return function decrease() {
countFromNum -= step;
return countFromNum;
}
}

// const countingDown = countdown(20, 2);

// console.log(countingDown());
// console.log(countingDown());
// console.log(countingDown());
Console
/index.html
-2:34