parent
55d8e3dbc0
commit
165551480a
@ -0,0 +1,60 @@
|
||||
// typeof operator, checks datatype of variables
|
||||
|
||||
console.log(typeof character);
|
||||
console.log(typeof characterIQ);
|
||||
console.log(typeof characterIsMarried);
|
||||
console.log(typeof testOfUndefined);
|
||||
console.log(typeof emptyValue);
|
||||
|
||||
// variables without values
|
||||
|
||||
let test1;
|
||||
let test2;
|
||||
let test3;
|
||||
let test4;
|
||||
|
||||
console.log(test1, test2, test3, test4);
|
||||
|
||||
// variables with assigned values
|
||||
|
||||
const varWithValue = "assigned value";
|
||||
let test = false;
|
||||
console.log(test);
|
||||
test = true;
|
||||
const num = 100;
|
||||
let operator;
|
||||
console.log(varWithValue, test, num, operator);
|
||||
|
||||
// variables in multiple lines
|
||||
|
||||
let characterFirstName = "Penny";
|
||||
let characterLastName = "Hofstadter";
|
||||
let characterIsMarriedStatus = true;
|
||||
let characterCountry = "USA";
|
||||
let characterAgeOf = 22;
|
||||
|
||||
console.log(
|
||||
characterFirstName,
|
||||
characterLastName,
|
||||
characterIsMarriedStatus,
|
||||
characterCountry,
|
||||
characterAgeOf
|
||||
);
|
||||
|
||||
//variables in single line
|
||||
|
||||
let firstNameTest = "Max",
|
||||
lastNameTest = "Mustermann",
|
||||
isMarriedTest = false,
|
||||
countryTest = "Musterland",
|
||||
ageTest = null;
|
||||
|
||||
console.log(firstNameTest, lastNameTest, isMarriedTest, countryTest, ageTest);
|
||||
|
||||
// age variables with initial values
|
||||
|
||||
let myAge = 35;
|
||||
let yourAge = 74;
|
||||
|
||||
console.log("I am " + myAge + " years old.");
|
||||
console.log("You are " + yourAge + " years old.");
|
||||
@ -1 +1,13 @@
|
||||
console.log('Hello, World!')
|
||||
console.log("Hello, World!");
|
||||
|
||||
// comments
|
||||
|
||||
// single comment: comments can make code readable
|
||||
|
||||
// Welcome to 30DaysOfJavaScript
|
||||
|
||||
/*
|
||||
multiline comment:
|
||||
comments can make code readable,
|
||||
easy to reuse and informative
|
||||
*/
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>30DaysOfJavaScript</title>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<title>30DaysOfJavaScript</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>30DaysOfJavaScript:03 Day</h1>
|
||||
<h2>Introduction</h2>
|
||||
<button onclick="alert('Welcome to 30DaysOfJavaScript!');">Click Me</button>
|
||||
<script src="./helloworld.js"></script>
|
||||
<script src="./introduction.js"></script>
|
||||
<script src="./variable.js"></script>
|
||||
<script src="./main.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<body>
|
||||
<h1>30DaysOfJavaScript:03 Day</h1>
|
||||
<h2>Introduction</h2>
|
||||
<button onclick="alert('Welcome to 30DaysOfJavaScript!');">Click Me</button>
|
||||
<script src="./helloworld.js"></script>
|
||||
<script src="./introduction.js"></script>
|
||||
<script src="./variable.js"></script>
|
||||
<script src="./main.js"></script>
|
||||
<script src="./datatypes.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,20 +1,37 @@
|
||||
// Declaring different variables of different data types
|
||||
|
||||
let firstName = 'Asabeneh' // first name of a person
|
||||
let lastName = 'Yetayeh' // last name of a person
|
||||
let country = 'Finland' // country
|
||||
let city = 'Helsinki' // capital city
|
||||
let age = 100 // age in years
|
||||
let isMarried = true
|
||||
let firstName = "Asabeneh"; // first name of a person
|
||||
let lastName = "Yetayeh"; // last name of a person
|
||||
let country = "Finland"; // country
|
||||
let city = "Helsinki"; // capital city
|
||||
let age = 100; // age in years
|
||||
let isMarried = true;
|
||||
|
||||
// Declaring variables with number values
|
||||
|
||||
const gravity = 9.81 // earth gravity in m/s2
|
||||
const boilingPoint = 100 // water boiling point, temperature in oC
|
||||
const PI = 3.14 // geometrical constant
|
||||
const gravity = 9.81; // earth gravity in m/s2
|
||||
const boilingPoint = 100; // water boiling point, temperature in oC
|
||||
const PI = 3.14; // geometrical constant
|
||||
|
||||
// Variables can also be declaring in one line separated by comma
|
||||
|
||||
let name = 'Asabeneh', //name of a person
|
||||
job = 'teacher',
|
||||
live = 'Finland'
|
||||
let name = "Asabeneh", //name of a person
|
||||
job = "teacher",
|
||||
live = "Finland";
|
||||
|
||||
// my own variables
|
||||
|
||||
let character = "Sheldon Cooper";
|
||||
console.log(character);
|
||||
|
||||
character = "Leonard Hofstadter";
|
||||
console.log(character);
|
||||
|
||||
const characterIQ = 173;
|
||||
console.log(characterIQ);
|
||||
console.log(character, characterIQ);
|
||||
|
||||
const characterIsMarried = true;
|
||||
let testOfUndefined;
|
||||
let emptyValue = null;
|
||||
console.log(characterIsMarried, testOfUndefined, emptyValue);
|
||||
|
||||
Loading…
Reference in new issue