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..fe5dbf3 --- /dev/null +++ b/01_Day_Introduction/01_day_starter/datatypes.js @@ -0,0 +1,6 @@ +// Use the typeof operator to check data types + +console.log(typeof name); +console.log(typeof isStudent); +console.log(typeof age); +console.log(typeof favoriteColor); diff --git a/01_Day_Introduction/01_day_starter/index.html b/01_Day_Introduction/01_day_starter/index.html index 7ed5b19..c1cc0e5 100644 --- a/01_Day_Introduction/01_day_starter/index.html +++ b/01_Day_Introduction/01_day_starter/index.html @@ -13,6 +13,7 @@ + diff --git a/01_Day_Introduction/01_day_starter/introduction.js b/01_Day_Introduction/01_day_starter/introduction.js index 316199c..a3b02eb 100644 --- a/01_Day_Introduction/01_day_starter/introduction.js +++ b/01_Day_Introduction/01_day_starter/introduction.js @@ -1 +1,3 @@ -console.log('Welcome to 30DaysOfJavaScript') \ No newline at end of file +console.log('Welcome to 30DaysOfJavaScript') + +//comments can make code readable \ No newline at end of file diff --git a/01_Day_Introduction/01_day_starter/main.js b/01_Day_Introduction/01_day_starter/main.js index 2b952bc..f1195ec 100644 --- a/01_Day_Introduction/01_day_starter/main.js +++ b/01_Day_Introduction/01_day_starter/main.js @@ -1,4 +1,11 @@ // the variable values can be accessed from other variable.js file +/* console.log(firstName, lastName, country, city, age, isMarried) console.log(gravity, boilingPoint, PI) // 9.81, 100, 3.14 -console.log(name, job, live) \ No newline at end of file +console.log(name, job, live) +*/ +//welcome to 30DaysofJavaScript + +/* comments can make code readable + easy to reuse and informative +*/ \ No newline at end of file diff --git a/01_Day_Introduction/01_day_starter/variable.js b/01_Day_Introduction/01_day_starter/variable.js index 62558cb..bc6b3ff 100644 --- a/01_Day_Introduction/01_day_starter/variable.js +++ b/01_Day_Introduction/01_day_starter/variable.js @@ -1,20 +1,48 @@ -// Declaring different variables of different data types +// Declare and assign string data type +const name = 'Gideon'; -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 +// Declare and assign boolean data type +const isStudent = true; -// Declaring variables with number values +// Declare a variable without assignment (undefined) + //let age; -const gravity = 9.81 // earth gravity in m/s2 -const boilingPoint = 100 // water boiling point, temperature in oC -const PI = 3.14 // geometrical constant +// Declare and assign null data type +const favoriteColor = null; -// Variables can also be declaring in one line separated by comma +// Declaring four variables without assigning values +let gideon +let asabeneh +let gitHub +let nike -let name = 'Asabeneh', //name of a person - job = 'teacher', - live = 'Finland' +// Declaring four variables with assigned values +let randomName = 'Eren'; +let year = 2023; +let month = 'August'; +let favoriteFruit = 'apple'; + +// Declaring variables in multiple lines + /* const firstName = 'Gideon'; + const lastName = 'Buba'; + let isMarried = True; + let country = 'Nigeria'; + const age = 21; */ + +// Declaring varibles in a signle line +let firstName = 'Gideon', lastName = 'Buba', isMarried = true, age = 21; + +//variables to log to browser console +myAge = 21; +yourAge = 30; + +console.log('I am', myAge , 'years old'); +console.log('I am', yourAge, 'years old'); + + + +// Print the variables to the console +console.log('Name:', name); +console.log('Is Student:', isStudent); +console.log('Age:', age); +console.log('Favorite Color:', favoriteColor); diff --git a/01_Day_Introduction/variable.js b/01_Day_Introduction/variable.js index f5872af..8ca5187 100644 --- a/01_Day_Introduction/variable.js +++ b/01_Day_Introduction/variable.js @@ -15,3 +15,6 @@ const PI = 3.14 // geometrical constant let name = 'Asabeneh', //name of a person job = 'teacher', live = 'Finland' + +// Varibles of different data types from excercises +