scrimba
Frontend Career Path
Code reviews
Code Reviews
Your first scrim-based code review
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

Your first scrim-based code review
AboutCommentsNotes
Your first scrim-based code review
Expand for more info
index.js
run
preview
console
function getdiscount(code) {
let promo = promos.find(promo => promo.code === code)
console.log(promo)

if (promo !== undefined && promo.isActive) {
console.log(`You get a ${promo.amount}% discount!`)
return promo.amount / 100;
}
return 0;
}

function calculatefinalprice(basePrice, userCode) {
if (userCode) {
const discount = getdiscount(userCode)
const finalPrice = basePrice - basePrice * discount
return finalPrice;
} else {
return basePrice;
}
}

const promos = [
{ code: 'TOTALLY10', amount: 10, isActive: true },
{ code: 'PLENTY20', amount: 20, isActive: false },
{ code: 'NIFTY50', amount: 50, isActive: true },
{ code: 'WHOPPING75', amount: 75, isActive: true },
{ code: 'YOLOFREE', amount: 100, isActive: false },
]
Console
/index.html
-1:58