Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
41 views

JavaScript Assignment

This document contains 7 JavaScript coding challenges: 1) Prompt for and display the larger of two numbers. 2) Use a conditional to display the sign (+ or -) of a given number. 3) Prompt for and display the larger of five numbers. 4) Use a for loop to iterate from 0 to 15 and display whether each number is even or odd. 5) Compute the average of student marks and assign a letter grade. 6) Iterate from 1 to 100, printing "Fizz" for multiples of 3, "Buzz" for multiples of 5, and "FizzBuzz" for multiples of both. 7) Use nested for loops to print a star pattern.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

JavaScript Assignment

This document contains 7 JavaScript coding challenges: 1) Prompt for and display the larger of two numbers. 2) Use a conditional to display the sign (+ or -) of a given number. 3) Prompt for and display the larger of five numbers. 4) Use a for loop to iterate from 0 to 15 and display whether each number is even or odd. 5) Compute the average of student marks and assign a letter grade. 6) Iterate from 1 to 100, printing "Fizz" for multiples of 3, "Buzz" for multiples of 5, and "FizzBuzz" for multiples of both. 7) Use nested for loops to print a star pattern.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Write a JavaScript program that accepts two numbers in two prompts and
displays the larger one in the console.

2. Write a JavaScript conditional statement to find the sign of a number. Display


an alert box with the specified sign.

Sample: 3
Output : The sign is +

Sample: -5
Output : The sign is -

3. Write a JavaScript program that accepts five numbers in five prompts and
displays the larger one in the console.

4. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it
will check if the current number is odd or even, and display a message to the
screen.
Sample Output :
"0 is even"
"1 is odd"
"2 is even"
----------
----------

5. Write a JavaScript program which computes the average marks of the


following students Then, this average is used to determine the corresponding
grade.

The grades are computed as follows :


Range Grade

<60 F

<70 D

<80 C

<90 B

<100 A

6. Write a JavaScript program which iterates the integers from 1 to 100. But for
multiples of three print "Fizz" instead of the number and for the multiples of five
print "Buzz". For numbers which are multiples of both three and five print
"FizzBuzz".

7. Write a JavaScript program to construct the following pattern, using a nested


for loop.

*
**
***
****
*****

You might also like