We learned about how to use switch statements, if/else statements effectively. We learned about the different ways a switch statement can be used, inconjunction with comparitive operators. After learning these skills, everyone completed a call activity independently, creating switch and if statements that provide the user with information regarding students grades. This activity lasted for an hour and thirty minutes and it tested our ability to effectively use switch, if and else statements. We also particularly the difference between an integer classed a string compared to an integer. This operattion console.log("24" != 24); has an output of 'false' as javascript converts all data types used to an integer (including strings) to match eachother. The statement asks whether both data types are not equal, which javascript returns a value of false.
We practised this skill that we learnt indepedently to test our knowledge and understanding of switch, if and else statements. By completing this task, we were able to have a greater understanding of how these statements can be implemented for real life uses and situations. We also learned about ternary operators, which are a simplier one liner version to if and switch statements. By using ternary opeartors, we are able to simplify our code and make it easier to read. Ternary operators will set a variable depending if the condition is true or false, using the same principal as an if statement.
While learning and using this skill, I found out that if statements and case statements are very similar to eachother and can almost be treated the same. I also learnt that ternary operators are a simiplified solution to if statements. While learning these skills, I struggled to find a solution to completing the indpendent class activity. Although, I was able to overcome this issue by creating a plan that I developed using any ideas I came up to find a solution. By following the plan that I created, I was able to create an efficent solution to the class activity. Another problem that I struggled with was deciding when to use if and switch statements. To begin with I was not sure how to lay it out, so deciding this was quite hard to begin with. Although after developing a plan I was able to make an effective decision on when I should use if and switch statements.