scrimba
Learn Typescript
Learn primitive types
Boolean Types mini-challenge
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

Boolean Types mini-challenge
AboutCommentsNotes
Boolean Types mini-challenge
Expand for more info
index.ts
run
preview
console
// Boolean Types mini-challenge
// if the last reviewer is a loyalty User, can you add a star to the end of their name?
// please do so in the existing function, and make sure to declare what type of
// parameters the function takes.

const reviewTotalDisplay = document.querySelector('#reviews')

const reviews = [
{
name: 'Sheia',
stars: 5,
loyaltyUser: true,
date: '01-04-2021'
},
{
name: 'Andrzej',
stars: 3,
loyaltyUser: false,
date: '28-03-2021'
},
{
name: 'Omar',
stars: 4,
loyaltyUser: true,
date: '27-03-2021'
},
]

// Solution
function showReviewTotal (value : number, reviewer: string) {
reviewTotalDisplay.innerHTML = 'review total ' + value.toString() + '| last reviewed by ' + reviewer
}

showReviewTotal(reviews.length, reviews[0].name)

Console
/index.html
-5:24