scrimba
Learn Typescript
Learn primitive types
Strings 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

Strings Types mini-challenge
AboutCommentsNotes
Strings Types mini-challenge
Expand for more info
index.ts
run
preview
console
// String Types mini-challenge
// Write a function that will display the most recent reviewers name next to the review total,
// making sure to assign a type to the parameter, to prevent unwanted behaviour.

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) {
reviewTotalDisplay.innerHTML = 'review total ' + value.toString()
}

showReviewTotal(reviews.length)
Console
/index.html
-3:19