Sharp Tutorial
js variable

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

Java Script

  • java script home
  • introduction
  • Variable Declare & Make Comment
  • operator
  • if else
  • loop
  • Array
  • Function
  • Java Script Objects
  • Java Script DOM

JS based examples

  • two number sum and diff programs
  • Pattern program in java script
  • zumble word quiz
  • Random number guess program
  • calculator in java script
  • digital clock in java script

HTML

  • HTML Home
  • Introduction
  • Commonly used tags
  • Formatting
  • Working with class
  • Apply Css
  • Layout
  • Link / Image
  • Html Forms
  • Html Tables
  • Responsive Design

CSS

  • Introduction
  • Types of Css
  • Background and Color
  • Css Formatting
  • Css Layout
  • Css Animation
  • Css Table
  • Css Effects
  • Css Pagination
  • Css Media Query

Java Script Variable

Java Script variable may be used to store a value and declared as var                                  var a=10, here 10 is stored in variable a . Variables may be local and global variable.            Variable type depends on the value it stores.                                                                       eg                                                                                                                                var i=10;                          (integer value)                                                                          var name=”Sharp Tutorial” (String Value)

prompt() is used to take the input from the user and parseInt() to convert string to int.

prompt() :  method to take input from user

parseInt(): method to convert string value to int type

alert(“Pop Up”) : to display the msg box in pop up alertbox

Program to Take two number as input and pop up their sum

<html>
<title>JS introduction</title>
<head>
<script>
var n1=parseInt(prompt("enter first number"));
var n2=parseInt(prompt("enter second number"));
var n=n1+n2;
alert("sum="+n);
</script>
</head>
</body>
</body>
</html>
 
[codepen_embed height="265" theme_id="default" slug_hash="jOEMvpQ" default_tab="js,result" user="rajputadesh"]See the Pen jOEMvpQ by rajput adesh (@rajputadesh) on CodePen.[/codepen_embed]

How to make comment in java Script

// this is single line comment and not executed this line

/*

multiline comment and skipped the whole block

*/

<html>
<title>JS introduction</title>
<head>
<script>
// single line comment
/* multi line comment
this line will not be executed */
</script>
</head>
</body>
</html>

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial