Use an array element as a case statement in switch
posted 1 year ago
Output of following code is Circle
İn my opinion array index starts with 0. And shapes="Square". It will match with case "Square". Output must be Square. What is my wrong?
If i changed switch (shapes) to switch (shapes) the output will be "Square" and changed switch (shapes) to switch (shapes) the output will be "Triangle"
Nil. Hatamova wrote:Sorry
I hope i will not do the same in exam. I need to be more carefully
No need to apologize! We are all here to learn and most of the times you learn much more from mistakes (failure) than from success.
And it's much better to make such a mistake here than on the actual exam But you have indeed to be much more careful and pay close attention to details. That's one of the reasons why the exam is very hard (difficult): you have to be really focused and read every question and code snippet very carefully.