• 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

if else statements

Angelo Brunetti - June 14, 2022 1 Comment

An if else statement is a way of checking something in your JavaScript code. I we want to know if a number is equal to 5, we can use an if else statement. If we were to be speaking this in English, and not in JavaScript, it would sound like: if this number is equal to 5 then do something, if not then do something else. I JavaScript it would look like: 

In the example below our “5” is a “10”

This code consists of four parts. 1) line one is the if statement. 2) “thisNumber == 10” is the Boolean expression. 3) “==” is the operator. 4) else statement is in line three.

An else statement is not necessary. You could just have an if statement, or several if statement in a row.

Reader Interactions

Comments

  1. Madison Gordon says

    June 14, 2022 at 7:16 pm

    I didn’t realize that we could have an if statement without an else statement, that is something so good to know. I found the if/else statements to be quite easy because all you really have to do is fill in based on the standard “formula” of writing one out like you mentioned as the four parts.

    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