JavaScript Program To Print Hello World
JavaScript Program To Print Hello World
World
1. Using alert()
The alert() method displays an alert box over the current window with the
specified message.
Source Code
// the hello world program
alert("Hello, World!");
2. Using document.write()
document.write() is used when you want to print the content to the HTML
document.
// the hello world program
document.write('Hello, World!');
If you know the base and height of a triangle, you can find the area using
the formula:
console.log(
`The area of the triangle is ${areaValue}`
);
console.log(
`The area of the triangle is ${areaValue}`
);
// conversion factor
const factor = 0.621371
// calculate miles
const miles = kilometers * factor
Output
Here, the kilometers variable is used to store the kilometer value from the
user. Then kilometer value is multiplied with factor to convert into miles.
// calculate fahrenheit
const fahrenheit = (celsius * 1.8) + 32
Output
In the above program, the user enters the celsius value and is stored in
the celsius variable. Then the fahrenheit formula is used to convert celsius
value to fahrenheit.