diff --git a/solutions/day-01/day-01_exercises.js b/solutions/day-01/day-01_exercises.js new file mode 100644 index 0000000..c5e66d3 --- /dev/null +++ b/solutions/day-01/day-01_exercises.js @@ -0,0 +1,3 @@ +// comments can make code readable. +// Welcome to 30DaysOfJavaScript +/* comments can make code readable, easy to use and informative */ diff --git a/solutions/day-01/day-01_variable.js b/solutions/day-01/day-01_variable.js new file mode 100644 index 0000000..948c0a5 --- /dev/null +++ b/solutions/day-01/day-01_variable.js @@ -0,0 +1,60 @@ +// Create a variable.js file and declare variables and assign string, boolean, undefined and null data types + +let fullName = "John Doe"; +let ageNow = 50; +let isDivorced = true; +let car = undefined; +let kids = null; + +console.log( + typeof "fullName", + typeof ageNow, + typeof isDivorced, + typeof car, + typeof kids +); + +let fruit = null; +let vegetable = null; +let fish = null; +let meat = null; + +console.log(fruit, vegetable, fish, meat); + +let carModel = "Toyota"; +let yearMade = 2019; +let price = 100000; +let color = "red"; + +console.log(carModel, yearMade, price, color); + +let nameFirst = "Daniel"; +let nameLast = "Fernandez"; +let countryOfOrigin = "Spain"; +let currentAge = 35; +let maritalStatus = "single"; + +let name1 = "John", + name2 = "Doe", + ethnicity = "Indian", + personAge = 50, + marriageStatus = "married"; + +console.log(nameFirst, nameLast, countryOfOrigin, currentAge, maritalStatus); +console.log(name1, name2, ethnicity, personAge, marriageStatus); + +// Array creation +let details = [ + (nameFirst = "John"), + (nameLast = "Doe"), + (countryOfOrigin = "USA"), + (currentAge = 50), + (maritalStatus = "single"), +]; + +console.log(details); + +const myAge = 35; +const yourAge = 50; + +console.log(`I am ${myAge} years old. and you are ${yourAge} years old.`); diff --git a/solutions/day-01/helloworld.js b/solutions/day-01/helloworld.js new file mode 100644 index 0000000..019c0f4 --- /dev/null +++ b/solutions/day-01/helloworld.js @@ -0,0 +1 @@ +console.log("Hello World!"); diff --git a/solutions/day-01/index.html b/solutions/day-01/index.html new file mode 100644 index 0000000..8801bb6 --- /dev/null +++ b/solutions/day-01/index.html @@ -0,0 +1,17 @@ + + + + + + 30 Days of Javascript + + + + + + + + + + + diff --git a/solutions/day-01/introduction.js b/solutions/day-01/introduction.js new file mode 100644 index 0000000..2768eca --- /dev/null +++ b/solutions/day-01/introduction.js @@ -0,0 +1,7 @@ +console.log("welcome to 30 Days of JS"); +// Data types check: +console.log(typeof "Asabeneh"); // string +console.log(typeof 5); // number +console.log(typeof true); // boolean +console.log(typeof null); // object type +console.log(typeof undefined); // undefined diff --git a/solutions/day-01/main.js b/solutions/day-01/main.js new file mode 100644 index 0000000..a4de964 --- /dev/null +++ b/solutions/day-01/main.js @@ -0,0 +1,24 @@ +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; + +console.log(firstName, lastName, country, city, age, isMarried); + +// Declaring variables with number values +const gravity = 9.81; // earth gravity in m/s2 +const boilingPoint = 100; // water boiling point, temperature in °C +const PI = 3.14; // geometrical constant +console.log(age, gravity, boilingPoint, PI); + +// Returns 9.81 100 3.14 + +// Variables can also be declaring in one line separated by comma, however I recommend to use a seperate line to make code more readble +let name = "Asabeneh", + job = "teacher", + live = "Finland"; +console.log(name, job, live); + +// Returns Asabeneh teacher Finland diff --git a/solutions/day-01/style.css b/solutions/day-01/style.css new file mode 100644 index 0000000..4bed79f --- /dev/null +++ b/solutions/day-01/style.css @@ -0,0 +1,7 @@ +body { + display: flex; + align-items: center; + justify-content: center; + background-color: grey; + height: 500px; +} diff --git a/solutions/day-02/index.html b/solutions/day-02/index.html new file mode 100644 index 0000000..f9fa146 --- /dev/null +++ b/solutions/day-02/index.html @@ -0,0 +1,13 @@ + + + + + + Day 2 + + + + + + + diff --git a/solutions/day-02/main.js b/solutions/day-02/main.js new file mode 100644 index 0000000..22a89a5 --- /dev/null +++ b/solutions/day-02/main.js @@ -0,0 +1,56 @@ +console.log("Day 2: Data types"); +console.log("Exercise: Level 1"); + +let challenge = " 30 Days Of Javascript "; +console.log(challenge); +console.log(challenge.length); +console.log(challenge.toUpperCase()); +console.log(challenge.toLowerCase()); +console.log(challenge.slice(0, 2)); +console.log(challenge.slice(3, 21)); +console.log(challenge.includes("script")); +console.log(challenge.split()); +console.log(challenge.split(" ")); + +let companies = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon"; +console.log(companies.split(",")); + +console.log(challenge.replace("Javascript", "Python")); +console.log(challenge.charAt(15)); +console.log(challenge.indexOf("a")); +console.log(challenge.lastIndexOf("a")); + +let sentenceA = + "You cannot end a sentence with because because because is a conjunction"; + +console.log(sentenceA.indexOf("because")); +console.log(sentenceA.lastIndexOf("because")); +console.log(sentenceA.search("because")); + +console.log(challenge.trim()); +console.log(challenge.startsWith("30")); +console.log(challenge.endsWith("Javascript")); +console.log(challenge.match("a")); +console.log(challenge.match(/a/gi)); // g = global, i = case insensitive => matches all a's in the string regardless of case. +console.log("30 Days of".concat(" Javascript")); +console.log(challenge.repeat(2)); + +console.log("Exercise: Level 2"); + +let sentenceB = + "There is no exercise better for the heart than reaching down and lifting people up."; + +console.log(sentenceB); + +let sentenceC = + "Love is not patronizing and charity isn't about pity, it is about love. Charity and love are the same -- with charity you give love, so don't just give money but reach out your hand instead."; + +console.log(sentenceC); + +console.log(typeof "10" == 10); +console.log(parseInt("10") == 10); +console.log(parseFloat("9.8" === 10)); +console.log(Math.round(parseFloat("9.8")) === 10); + +let sentenceD = "python jargon"; +console.log(sentenceD.indexOf("on") !== -1); diff --git a/solutions/day-02/style.css b/solutions/day-02/style.css new file mode 100644 index 0000000..4bed79f --- /dev/null +++ b/solutions/day-02/style.css @@ -0,0 +1,7 @@ +body { + display: flex; + align-items: center; + justify-content: center; + background-color: grey; + height: 500px; +}