A ‘Level Paper-1 Notes JavaScript Programming
JavaScript Programming
Practice questions
Q1. How find the sum and average of five nos.
Q2. How find the sum of any FIVE numbers using FOR…NEXT loop.
Q3. How find the sum of any FIVE numbers using While loop.
Q4. How to print 0-------9 numbers with Text using while loop.
Q5. Write a JavaScript conditional statement to find the largest of THREE
numbers
6 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"
----------
----------
Q7. Write a JavaScript program to check whether the number is ODD or EVEN
when a number is input.
Q8. Write a JavaScript program to convert temperature from centigrade to
Fahrenheit.
Mr. Fazal-E-Malik PhNo: 0333-4732544 Page 1
A ‘Level Paper-1 Notes JavaScript Programming
Q9. Write a JavaScript program to calculate student grades of a student when
marks are input in percentage using IF….ELSE conditional statement only
for FIVE students.
Grades criteria are shown below:
91----100 is A*
81----90 is A
71----80 is B
61----70 is C
51----60 is D
41----50 is E
Else you got Fail
Q10. Write a JavaScript program to calculate multiplication and division of two
numbers (input from user).
Sample Form:
//The HTML <span> tag is used for grouping and applying styles to inline elements. There
is a difference between the span tag and the div tag. The span tag is used with inline
elements whilst the div tag is used with block-level content.
<html>
<head>
Mr. Fazal-E-Malik PhNo: 0333-4732544 Page 2
A ‘Level Paper-1 Notes JavaScript Programming
<title>JavaScript program to calculate multiplication and division of two numbers </title>
<body>
<form>
1st Number : <input type="text" id="firstNumber" /><br>
2nd Number: <input type="text" id="secondNumber" /><br>
<input type="button" onClick="multiplyBy()" Value="Multiply" />
<input type="button" onClick="divideBy()" Value="Divide" />
</form>
<p>The Result is : <br>
<span id = "result"></span>
</p>
<script>
function multiplyBy()
num1 = document.getElementById("firstNumber").value;
num2 = document.getElementById("secondNumber").value;
document.getElementById("result").innerHTML = num1 * num2;
function divideBy()
num1 = document.getElementById("firstNumber").value;
num2 = document.getElementById("secondNumber").value;
document.getElementById("result").innerHTML = num1 / num2;
</script>
</body>
Mr. Fazal-E-Malik PhNo: 0333-4732544 Page 3
A ‘Level Paper-1 Notes JavaScript Programming
</html>
Mr. Fazal-E-Malik PhNo: 0333-4732544 Page 4