0% found this document useful (0 votes)
26 views

Assignment 3 Javascript 2

This document contains instructions for 4 parts of a Java Script assignment for an Introduction to Programming course. Part 1 instructs students to write a script that prompts the user to enter a number, checks if it is even or odd using an if statement, displays the result in an alert, and allows the user to continue entering numbers in a loop until choosing to quit. Part 2 asks students to create a function that checks the grade status (A, B, C, or F) based on a passed parameter, and call the function to display statuses for 5 students. Part 3 provides directions to code a button that toggles its label between "ON" and "OFF" using an event handler and if
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Assignment 3 Javascript 2

This document contains instructions for 4 parts of a Java Script assignment for an Introduction to Programming course. Part 1 instructs students to write a script that prompts the user to enter a number, checks if it is even or odd using an if statement, displays the result in an alert, and allows the user to continue entering numbers in a loop until choosing to quit. Part 2 asks students to create a function that checks the grade status (A, B, C, or F) based on a passed parameter, and call the function to display statuses for 5 students. Part 3 provides directions to code a button that toggles its label between "ON" and "OFF" using an event handler and if
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Zayed University

THE COLLEGE OF INFORMATION


TECHNOLOGY

CIT 225: Introduction to Programming and Problem Solving


Java Script Assignment

Part 1: If Statements, Loops and Pop up Messages

Write a script that asks the user to enter a number through a prompt dialog. You have to
test the number if it is even or odd number and display the result in an alert dialog. Ask
the user if he wants to continue in entering the numbers. If yes then you have to repeat
the above steps, if no then the script ends.

Part 2: If Statements & Functions

Write a script that contains a function getStatus() that you can pass a grade as a parameter
and have it display based on the following:
A is a grade of 90 or greater
B is a grade of 80 or greater, but less than 90
C is a grade of 70 or greater, but less than 80
F is any grade below 70

Demonstrate the function by printing out the grade for five students. One example of one
student could be:
document.write("Mary - ") + getStatus(94) + document.write("<BR>")

Part 3: If Statements & Events Handlers

Place a single button on a page that could be used as an ON/OFF switch. Design this
button so that the button is labeled "ON". When you click on the button its label should
change to "OFF". Clicking on it again should change it back to "ON" and so on.

Part 4: Loops

Write a script to print the numbers 1 through 20. Your results should be printed on 4 lines
with 5 numbers on each line. Be sure to put a space between the numbers that are on the
line. This will require a loop inside of a loop. I recommend that you get one loop working
and then add the second.

You might also like