JavaScript Basic Programs
1. Ask for the user’s first name and display the output message:
View     Try It
2. Ask for the user’s first name and then ask for
their surname
and display the output message:
View     Try It
3. Ask the user to enter two numbers. Add them together and display the answer as:
View     Try It
4. Ask the user to enter two numbers. Add them together and display the answer as:
View     Try It
5. Ask the user for their name and their age. Add 1 to their age and display the output:
View     Try It
6.Generate users lucky number (0-9) and display the output:
View     Try It
6a. Generate a sum as follows:
View     Try It
7.Write a program that will ask for a number of days and then will show how many hours, minutes and seconds are in that number of days. and display the output:
View     Try It
8. Ask the user to enter Original price of a material and discount in
percentage.
Calculate sale_price = original_price - discount amount;
discountAmount = orgPrice x (discount/100);
Display the output as follows:
View     Try It
9. Ask the user to enter two numbers. Print the result for all arithmetic operations:
View     Try It
10. Ask the user to enter three test scores and assign them to the test1, test2, and test3 variables.
Calculate the average of the three scores and assign the result to the average variable [average = (test1 + test2 + test3) / 3.0]
Display the average as:
View     Try It
11. Ask the user to enter temperature in Celsius and assign it to celsius variable.
Convert it in to fahrenheit = (9 / 5) * celsius + 32.
Display the temperture in fahrenheit as:
View     Try It
12. Ask the user to enter 4 subjects marks and assign them to
the 4 variables.
Calculate the total marks and the average of the marks.
[averageMarks = totalMarks / 4] Display the result as:
View     Try It
13. Ask the user to enter basic salary.
Calculate TA of 12% and DA of 10%.
Display Gross salary
[ta = basisSalaty x 12/100],
[da = basisSalaty x 10/100],
[grossSalaty = basisSalaty + ta + da]:
View     Try It
14. Develop a Mileage calculation application based on start reading, end reading and petrol
consumed.
[milage = (endReading - startReading)/petrolConsumed].
View     Try It
15. Develop a future value calculation application based on desired future
, annual interest rate and number of years investment.
[present_value = future_value / (1.0 + rate)**years].
View     Try It
16. Develop an average speed calculation application based on distance travelled and
time.
[speed = distanceTravelled / timeOfTravel].
View     Try It
17. Develop a BMI calculation application based on weight and height.
[bmi = weightKgs /(heightM * heightM)].
View     Try It
18. Develop an Area of Rectangle calculation application based on length
and bradth.
[area = length * breadth].
View     Try It
19. Develop a feet to meters convertion application based on input feet .
[meters = 0.305 * foots].
View     Try It
20. Develop a kilograms to pounds convertion application based on input kilograms .
[pound = 2.024 * kilo].