0

correct this code ?

tell me, correct so write that code? or needed write with 'if'? so what will be faster? https://code.sololearn.com/WMqe9wpZQWX8/?ref=app

5th Oct 2022, 5:34 PM
Анатолий Шмель
3 odpowiedzi
+ 2
Ternary Operator is a programming statement. “If-Else” is a programming block. The statement is faster than Block since there is fewer instructions. But the difference in speed will always be marginal, and therefore irrelevant. The decision of which to use is down to code readability. However the Ternary Operator is not suitable for executing a function or several statements. In this case, if else is more appropriate.
5th Oct 2022, 6:18 PM
Chris Coder
Chris Coder - avatar
0
What do you want it to do? If I read it correctly, x = 7, so a = 7. You could change the last part after the "?" And receive a different alert. instead of: x==7?7:0 try: x==7?24:0 It should alert 24.
5th Oct 2022, 5:37 PM
Ausgrindtube
Ausgrindtube - avatar
0
Ausgrindtube i mean, so what faster, 'if' or ternary condition?
5th Oct 2022, 5:38 PM
Анатолий Шмель