JS Shorthand

Steps to reproduce:
1]using if statement:
let compValue;
if(randomNum>=0&&randomNum<1/3){
compValue = 'Rock';
}
console.log(compValue)//Rock

2]using shorthand
randomNum>=0&&randomNum<1/3 && compValue='Rock';
=>This statement gives me an error stating ';' expected.javascript
let compValue: undefined.
Can anyone pls explain me this
Was this page helpful?