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

Javascript Basic

This document provides examples of JavaScript programs and functions to demonstrate basic JavaScript concepts and conditional logic. The examples include: 1) Displaying the current day and time. 2) Converting between Celsius and Fahrenheit. 3) Checking if numbers are the same and returning a value. 4) Finding the second lowest and highest numbers in an array. 5) Converting an amount to coins. 6) Calculating factorials. 7) Getting integers within a range. 8) Computing sums and averages. 9) Using conditional statements to sort numbers and find largest values. 10) Using for loops to iterate and check for even/odd numbers.

Uploaded by

Son Tung
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Javascript Basic

This document provides examples of JavaScript programs and functions to demonstrate basic JavaScript concepts and conditional logic. The examples include: 1) Displaying the current day and time. 2) Converting between Celsius and Fahrenheit. 3) Checking if numbers are the same and returning a value. 4) Finding the second lowest and highest numbers in an array. 5) Converting an amount to coins. 6) Calculating factorials. 7) Getting integers within a range. 8) Computing sums and averages. 9) Using conditional statements to sort numbers and find largest values. 10) Using for loops to iterate and check for even/odd numbers.

Uploaded by

Son Tung
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Basic

1. Create the Project named ChallengeConditionalRadioButton. If user select value and click OK
button then display: “You selelected ”+{value of radio button selected}
Extend your application, when user select value from radio button and click OK button then your page
will display image (search and get suite image online) of coressponding item, eg:

2. Write a JavaScript program to display the current day and time in the following format:
Sample Output : Today is : Tuesday.
Current time is : 10 PM : 30 : 38
3. Write a JavaScript program to convert temperatures to and from Celsius, Fahrenheit [Formula :
c/5 = (f-32)/9 [ where c = temperature in Celsius and f = temperature in Fahrenheit ]
Expected Output :
60°C is 140 °F
45°F is 7.222222222222222°C
4. Write a JavaScript program to check three given numbers, if the three numbers are same return
30 otherwise return 20 and if two numbers are same return 40
5. Write a JavaScript function which will take an array of numbers stored and find the second lowest
and second greatest numbers, respectively.
Sample array : [1,2,3,4,5]
Expected Output : 2,4
6. Write a JavaScript function to convert an amount to coins.
Sample function : amountTocoins(46, [25, 10, 5, 2, 1])
Here 46 is the amount. and 25, 10, 5, 2, 1 are coins.
Output : 25, 10, 10, 1
7. Write a JavaScript program to calculate the factorial of a number.
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all
positive integers less than or equal to n. For example, 5! = 5 x 4 x 3 x 2 x 1 = 120
8. Write a JavaScript program to get the integers in range (x, y).
Example : range(2, 9)
Expected Output : [3, 4, 5, 6, 7, 8]
9. Write a JavaScript program to compute the sum of an array of integers.
Example : var array = [1, 2, 3, 4, 5, 6]
Expected Output : 21
10. Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the
result.
Sample numbers : 0, -1, 4
Output : 4, 0, -1
11. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box
to show the result.
Sample numbers : -5, -2, -6, 0, -1
Output : 0
12. 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"
13. Write a JavaScript program which compute, the average marks of the following students Then,
this average is used to determine the corresponding grade:
14. Student Name Marks

David 80

Vinoth 77

Divya 88

Ishitha 95

Thomas 68

The grades are computed as follows :

Range Grade

<60 F

<70 D

<80 C

<90 B

<100 A

15.

You might also like