From 165551480acfbf66e08dacd1f9e071363d169668 Mon Sep 17 00:00:00 2001 From: Doris Wiebe Date: Sat, 20 Jan 2024 17:24:27 +0100 Subject: [PATCH] day 1 --- .../01_day_starter/datatypes.js | 60 +++++++++++++++++++ .../01_day_starter/helloworld.js | 14 ++++- 01_Day_Introduction/01_day_starter/index.html | 30 +++++----- .../01_day_starter/variable.js | 41 +++++++++---- 4 files changed, 116 insertions(+), 29 deletions(-) create mode 100644 01_Day_Introduction/01_day_starter/datatypes.js diff --git a/01_Day_Introduction/01_day_starter/datatypes.js b/01_Day_Introduction/01_day_starter/datatypes.js new file mode 100644 index 0000000..4effec6 --- /dev/null +++ b/01_Day_Introduction/01_day_starter/datatypes.js @@ -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."); diff --git a/01_Day_Introduction/01_day_starter/helloworld.js b/01_Day_Introduction/01_day_starter/helloworld.js index 8c9e2c0..24601a1 100644 --- a/01_Day_Introduction/01_day_starter/helloworld.js +++ b/01_Day_Introduction/01_day_starter/helloworld.js @@ -1 +1,13 @@ -console.log('Hello, World!') \ No newline at end of file +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 +*/ diff --git a/01_Day_Introduction/01_day_starter/index.html b/01_Day_Introduction/01_day_starter/index.html index 7ed5b19..ef45505 100644 --- a/01_Day_Introduction/01_day_starter/index.html +++ b/01_Day_Introduction/01_day_starter/index.html @@ -1,19 +1,17 @@ + + 30DaysOfJavaScript + - - 30DaysOfJavaScript - - - -

30DaysOfJavaScript:03 Day

-

Introduction

- - - - - - - - - \ No newline at end of file + +

30DaysOfJavaScript:03 Day

+

Introduction

+ + + + + + + + diff --git a/01_Day_Introduction/01_day_starter/variable.js b/01_Day_Introduction/01_day_starter/variable.js index 62558cb..064b931 100644 --- a/01_Day_Introduction/01_day_starter/variable.js +++ b/01_Day_Introduction/01_day_starter/variable.js @@ -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);