• Log In
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Digital Systems

Department of Management Information Systems, Temple University

Digital Systems

MIS 2101.712 ■ Summer 2022 ■ Steven E. Sclarow, AIA
  • Home
  • About
    • Course Materials
    • Course Requirements
    • Email Policy
    • Grading
    • Gradebook
    • Instructor
    • Temple and COVID-19
    • Zoom Requirements
  • Canvas Content
  • Coding Files
  • Helpdesk
  • Zoom Links
  • Video Vault
  • Diamond Peer Corner
  • Posts

week 11 blog post

Madison Gordon - June 13, 2022 3 Comments

In JavaScript we can use things called if/else statements. These are used if there are more than one possible outcome of something. Similar to our English language, I could say “if you are 21 years old you can drink, or else you are too young.”. In our code we could similarly say this through writing out an if/else statement. This would look something like:

if(age>=21) {

       alert(“You are of age to drink!”);

} else {

       alert(“You are underage.”);

}

The whole basis of an if/else statement is about making true/false statements. It is writing in code something that has two outcomes or multiple if you put multiple together. It allows you to code out if one thing happens here is your outcome, and if not well this will happen. In my example, “>=” means that when the first statement, “age”, is greater that or equal to “21”, then I tell you what would happen. And this lets us know that any age below 21 means you are underage and cannot drink alcohol. 

There are many more symbols like that one to create meaning within our statements. An important one is “&&”. This is known as a logical operator that means that both our first and second statement are both going to be true. For example, saying something like I am 21 and I am over the age of 20 gives the same outcome that I am legal to drink. My two statements could be, ‘const a=21; const b>20;’. We would use && by stating ‘console.log(a=21 && b>20);’ and that would create the same outcome as before ‘expected outcome(“You are of age to drink!”)’. 

Reader Interactions

Comments

  1. Meghan Gemelli says

    June 13, 2022 at 7:33 pm

    Hi Madison, you used a good example of how to write an if/else statement to perform an action, and made it easy to understand how they work in coding.

    Log in to Reply
  2. Grace Adams says

    June 13, 2022 at 10:45 pm

    Hi Madison. Your example was really greta. I think that it definitely shows how simply if/else statements can be if you don’t over complicate things. They way yours is written is very clear and easy to follow.

    Log in to Reply
  3. Zac Bloom says

    June 19, 2022 at 11:09 pm

    You used a great example which really illustrated how if/else statements are used in Java.

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

ANNOUNCEMENTS

Week 12 Questions

Loops tell the computer to run a function repeatedly. They are useful if … [More...] about Week 12 Questions

Weekly Questions: 13

When it comes to adding the structure to a web page HTML is used. When it … [More...] about Weekly Questions: 13

Week 11 Questions

The purpose of the if/else code in JavaScript is to execute a block of code … [More...] about Week 11 Questions

Weekly Questions: 12

Loops are a sequence of instructions that is repeated until a certain … [More...] about Weekly Questions: 12

Week 10 Questions

A function in JavaScript is a set of instructions that performs a task or … [More...] about Week 10 Questions

Week 9 Questions

A variable in JavaScript is the name of a storage location for data. For … [More...] about Week 9 Questions

Instructor

Steven E. Sclarow, AIA

Email: sclarow@temple.edu
Virtual Office Hour Availability: Tue, 10 - 11:00 AM, or by appointment. Please email me to schedule an appointment outside of my normal office hours.
Virtual Office: https://temple.zoom.us/j/94115790056

ITA CONTACT INFO

ITA
Name: Anna Boykis
Email: anna.boykis@temple.edu
ITA
Name: Jessica Rakhman
Email: jessica.rakhman@temple.edu

Helpful Links

FOX Laptop Policy
FOX Laptop Support

Gradebook

Installing-VS-Code-Windows
Installing-VS-Code-Mac-OS

Copyright © 2025 · Department of Management Information Systems · Fox School of Business · Temple University