let height = 40 let isCheck = true let rowHeight = height + (isCheck ? 50 : 20) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

let height = 40 let isCheck = true let rowHeight = height + (isCheck ? 50 : 20)

why would the answer be 90?

19th Mar 2020, 4:17 PM
Amber Mitchell
Amber Mitchell - avatar
2 Answers
+ 3
That is ternary Operator or conditional Operator you can say. If the condition provided is true than first part is executed otherwise second Your code is equivalent to : if (isCheck){ rowHeight = height + 50; } else { rowHeight = height + 50; }
19th Mar 2020, 4:22 PM
Raj Chhatrala
Raj Chhatrala - avatar
0
let height = 40 let isCheck = true let rowHeight = height + (isCheck ? 50 : 20)
20th Nov 2022, 10:55 AM
Nguyễn Thị Mỹ Hạnh
Nguyễn Thị Mỹ Hạnh - avatar