+ 2
The problem is the ternary operator (age>1)? .It cannot concatenate with another string because it is a calculate( compare) process , not a string. Modify : put all ternary operator in the parentheses "()": for example : instead "You are " + age * 1 + (age > 1) ? "years" : " year"; we write "You are " + (age * 1) + ((age > 1) ? "years" : " year"); Hope to help you
6th Mar 2022, 9:49 AM
Ueda
0
What is your expected output if age = 45?
6th Mar 2022, 5:59 AM
Simba
Simba - avatar