0

Age Converter

Okay, so im trying to make an age converter and your not going to say you 1 years old, 1 months, and 1 days old so i tried changing that from a metho somebody taught me which is an if statement i trie using and it did something https://code.sololearn.com/WGEqEcOTJ8WV

6th Mar 2022, 5:11 AM
Your Mom
Your Mom - avatar
5 Answers
+ 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
+ 1
I got it
6th Mar 2022, 6:01 AM
Your Mom
Your Mom - avatar
0
I want it to say 1year old, 1 month, 1day or something like fhat if tou know what i mena
6th Mar 2022, 5:33 AM
Your Mom
Your Mom - avatar
0
What is your expected output if age = 45?
6th Mar 2022, 5:59 AM
Simba
Simba - avatar
0
No, nevermind its fine
6th Mar 2022, 6:01 AM
Your Mom
Your Mom - avatar