Javascript Coding Challenges for Beginners Q3

Transcript

English (Auto-generated)

Hello everyone. Welcome to my coding challenge course for beginners. Again today we will be using to urinary operators in coding challenges. This challenge should help you get more comfortable with seeing the syntax and trust me it's not all that bad. So first of all you have to understand how to write a tyranny eri operator and it is usually written in the syntax so we have a condition and if this condition evaluates to be true, the first expression will be printed, otherwise the second expression will be printed. Yeah, so pasta video and come up with your own solution for this challenge. When you're ready we will work through this problem together now that you're ready, the current solution says that if there is rain while the weather equals rain then we will bring in the umbrella. Otherwise we will return good day. So how are we gonna use territory operator to solve this for now. I'm gonna write it on top of our if and else statement and you can see and compare between them. So our condition is if weather equal rain, we have the condition whether equal rain and the first condition is levering and umbrella. Otherwise we put a semi colon Good day and don't forget to return this statement. Otherwise it wouldn't work. So as you can see this conditional statement is exactly the same as if and else but just written with a question mark and a semi colon. So now let's check that this answer works. So I'm gonna save it, I'm gonna run the terminal so no 03 dot Js And as expected because we do have reined it evaluated to the first statement, which is bringing an umbrella because the statement is true. So thank you all for watching. I hope this cleared up some of the confusion between terran ERi operator and if else, statement, they are essentially the same thing but written in differently. Some people find Terran ERi operator more clean and concise, while other people is more comfortable seeing the if else statement as you can see Terron ERi operator does help you be able to return the problem within one line of code so you can keep that in mind and keep practicing and eventually you will be comfortable with using Terran ERi operator as well.
110 Views 0 Likes 0 Comments

This coding challenge will teach you how to use ternary operators to solve coding challenges.

Comment
Leave a comment (supports markdown format)