Collection if and for
Build lists with if and for inside the literal.
Example
var admin = true;
var menu = ["home", if (admin) "admin", for (var i in [1, 2]) "item$i"];
print(menu);Exercise
Conditional item.
[1, (c) 2]
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.