Skip to main content

Posts

Showing posts with the label else if

JavaScript Project Study: How To Create A Simple Todo List APP?

After I learned JavaScript loop and array, it's time to implement those codes into a simple project and see how it works. The course instructor leads us to create a small To Do List APP. Basically, when we open the web page, it will pop up a question:"What would you like to do?". Then we enter "new" and add a todo. If we want to check our todo list, we need to enter "list", so we can see our todos are stored in the console. The question will ask you again and again until you enter "quit" to end it. We create a HTML page and link to a separate JS file.  In the JS file, we start to write a  todos array . We leave the empty[] since we will enter data through the pop up question window.  Then, we create the pop up window by writing a prompt("What would you like to do?" So when we open the web page, it will pop up this question to ask you to enter your todos. Next, we use while loop to let the site keep ask...

JavaScript Basic: Three Conditional Keywords You Should Know

JavaScript conditionals is how you add logic to your programming and help you make decisions with code. For example, when we shop online and ready to pay our items, we will enter our credit card number, if our information is correct, it will match the code, and we will receive a confirmation message. If our credit card information is wrong, the code will send us an error message. There are three JS conditional keywords: If, Else If, and Else. How do we use those conditional keywords in JavaScript? If For example, if the website wants to send an message about your age is younger than 18, you can't enter the bar. if (age < 18) { console.log("Sorry, you are not old enough to enter the venue."); } Else If If your age is older than 18 but younger than 21, you can enter the bar but can not drink. else if (age < 21) { console.log("You can enter, but can not drink."); } Else If your age is older than 21, feel free to drink. ...