I am eager to implement the ternary operator in my code, but I keep encountering the following error message:
" Unexpected token, expected : "
Can someone enlighten me as to why this is happening?
Here is the initial code snippet I wrote:
const GetUp = (num) => {
for (let i = 1; i <= num; i++) {
if (i % 3 === 0) {
console.log('Get')
}
if (i % 5 === 0) {
console.log('Up')
}
if (i % 3 === 0 && i % 5 === 0) {
console.log('GetUp')
} else {
console.log(i)
}
}
}
GetUp(200)
And here is the updated version of my code:
const SetRuc = (num) => {
for (let i = 1; i <= num; i++) {
(i % 3 === 0) ? console.log('Set') :
(i % 5 === 0) ? console.log('Ruc') :
(i % 3 === 0 && i % 5 === 0) ? console.log('SetRuc') : console.log(i)
}
}
SetRuc(100)