Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 785 Bytes

js_cheatsheet.md

File metadata and controls

55 lines (39 loc) · 785 Bytes

Index

Basic

How to output

  1. console.log() - Output in the developer console.
var a = 50;
console.log(a);
  1. alert() - Output in the browser.
var a = 50;
alert(a);

How to take Input

prompt() function is used to take input.

var lastQuestion;
lastQuestion = prompt("How long the universe will last?: ");
console.log(lastQuestion);

Variables

Converting Between Values
  1. From String To Number:
var strNum = "3.14";
var num = Number(strNum);
console.log(strNum);
console.log(num);
  1. From Number to String:
var num = 2.72;
var strNum = String(num);
console.log(num);
console.log(strNum);
Working with Numbers

TODO

Conditional Statement