Java Script 1
Java Script 1
SAHRISH NAZ
WHAT IS JAVA SCRIPT
Brendan Eich developed JavaScript in 1995 at Netscape Communications:
• console.log()
• alert()
• document.write()
NOTE:
ALL CODES CAN BE EXUCUTED WITH SINGLE OR DOUBLE INVERTED
COMMAS
• CASE SENSTIVE LANGUAGE
SUM 2 NUMBERS
const num1 = 5;
const num2 = 3;
The above program asks the user to enter two numbers. Here, prompt() is used to take
inputs from the user. parseInt() is used to convert the user input string to number.
Finally, the sum is displayed. To display the result, we have used the template literal ` `.
This allows us to include variables inside strings.
To include variables inside ``, you need to use the ${variable} format.
SAMPLE PROGRAM
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript in Body</h2>
<p id="demo"></p>
<script>
</script>
</body>
</html>