I DONT UNDERSTAND | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I DONT UNDERSTAND

why should I use if or elseif or for or etc ? while I can just omit them and only use alert or document.write ?

8th Aug 2018, 2:35 PM
Armann
Armann - avatar
6 Answers
+ 5
If else and loops are fundamental of every language and you can find it in every code. You should not use doc.write in real website it is just for example purpose. Main use of Js is to add interactivity and to change html and css as per requirements. Hope this helps ☺️☺️.
8th Aug 2018, 2:50 PM
Meet Mehta
Meet Mehta - avatar
+ 5
If this also helps Conditional Statement : Conditional statement are used to control the flow means if some condition is true than only execute certain statement. Loops : Loops are used to repeat a block of statement if certain condition are true.
8th Aug 2018, 4:32 PM
Meet Mehta
Meet Mehta - avatar
+ 4
Alert and loops are completely different concept so dont get confuse in that. They are not alternatives. And happy it helped☺️☺️.
8th Aug 2018, 2:55 PM
Meet Mehta
Meet Mehta - avatar
+ 3
There is called conditional statement, we use if and else to let program runs 2 different state based on different condition. This is what's program language meant for, it helps us to decide the actions to run based on different inputs.
8th Aug 2018, 2:59 PM
Calviղ
Calviղ - avatar
+ 2
oh , thank you . thumbs up 👍
8th Aug 2018, 2:53 PM
Armann
Armann - avatar
8th Aug 2018, 2:53 PM
Armann
Armann - avatar