I tried to use if else if and else method.
However, it’s showing 5 instead of 20.
May I know why?
Your first screen returns the wrong result because you use the assignment operator rather than the comparison operator:
if( quality = 'bad' )
That condition is always true because you assign the value ‘bad’ to quality
.
That needs to be
if( quality === 'bad' )
Your 2nd code looks ok. The error message looks like it was thrown before you changed the code. In the error message there is still a space between the first argument and the comma which in your code in the left window is gone.