diff --git a/solutions/day-01/variable.js b/solutions/day-01/variable.js index 6e4dd6a..0129e1e 100644 --- a/solutions/day-01/variable.js +++ b/solutions/day-01/variable.js @@ -1,16 +1,19 @@ -let a = "string"; -let b = true; -let c = null; -let d = undefined; +let a = "string" +let b = true +let c = null +let d = undefined -let firstName = "Eligijus"; -let lastName = "Dzikavicius"; -let isMarried = false; -let age = 17; +let firstName = "Eligijus" +let lastName = "Dzikavicius" +let isMarried = false +let age = 17 let live = "Lithuania" -let myAge = 17; -let yourAge = 30; +let myAge = 17 +let yourAge = 30 -console.log("I am " + myAge + " years old."); -console.log("You are " + yourAge + " years old."); \ No newline at end of file +console.log("I am " + myAge + " years old.") +console.log("You are " + yourAge + " years old.") + +let js = "JavaScript" +console.log(js.length) \ No newline at end of file diff --git a/solutions/day-02/index.html b/solutions/day-02/index.html new file mode 100644 index 0000000..d51862f --- /dev/null +++ b/solutions/day-02/index.html @@ -0,0 +1,13 @@ + + + + + + Day 2 Exercises + + + + + + + \ No newline at end of file diff --git a/solutions/day-02/level1.js b/solutions/day-02/level1.js new file mode 100644 index 0000000..641f584 --- /dev/null +++ b/solutions/day-02/level1.js @@ -0,0 +1,34 @@ +let challenge = "30 Days Of JavaScript" +console.log(challenge) +console.log(challenge.length) +console.log(challenge.toUpperCase()) +console.log(challenge.toLowerCase()) +console.log(challenge.substring(3)) +console.log(challenge.substring(0,3)) +console.log(challenge.includes("Script")) +console.log(challenge.split()) +console.log(challenge.split(" ")) +console.log(challenge.replace("JavaScript", "Python")) +console.log(challenge.charAt(15)) +console.log(challenge.charCodeAt(11)) +console.log(challenge.indexOf("a")) +console.log(challenge.lastIndexOf("a")) +console.log(challenge.startsWith("3")) +console.log(challenge.endsWith("t")) +console.log(challenge.match(/a/gi)) +console.log(challenge.repeat(2)) +console.log("30 Days of ".concat("JavaScript")) + + +let companies = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon" +console.log(companies.split(" ,")) +console.log(companies.split(", ")) + +let sentence = "You cannot end a sentence with because because because is a conjunction" +console.log(sentence.indexOf("because")) +console.log(sentence.lastIndexOf("because")) +console.log(sentence.search("because")) + +console.log(" 30 Days Of JavaScript ".trim()) + + diff --git a/solutions/day-02/level2.js b/solutions/day-02/level2.js new file mode 100644 index 0000000..046f1fb --- /dev/null +++ b/solutions/day-02/level2.js @@ -0,0 +1,26 @@ +console.log("The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help one another.\n") + +console.log("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.\n") + +let num1 = parseInt("10") +let num2 = parseFloat("9.8") +if (num2 !== 10) { + num2 = 10 +} + + +console.log(num1) +console.log(num2) +console.log("jargon python".includes("on")) +console.log("I hope this course is not full of jargon.".includes("jargon")) +console.log(Math.floor(Math.random() * 101)) +console.log(Math.floor(Math.random() * 51) + 50) +console.log(Math.floor(Math.random() * 257)) + +let str = "JavaScript" +let randomNumber = Math.floor(Math.random() * str.length) +let randomCharacter = str[randomNumber] +console.log(randomCharacter) + +console.log("1 1 1 1 1\n2 1 2 4 8\n3 1 3 9 27\n4 1 4 16 64\n5 1 5 25 125") +console.log("You cannot end a sentence with because because because is a conjunction".substring(31,54)) \ No newline at end of file diff --git a/solutions/day-02/level3.js b/solutions/day-02/level3.js new file mode 100644 index 0000000..9437b32 --- /dev/null +++ b/solutions/day-02/level3.js @@ -0,0 +1,27 @@ +let love = "Love is the best thing in this world. Some found their love and some are still looking for their love" + +console.log(love.match(/love/gi).length) + +let because = "You cannot end a sentence with because because because is a conjunction" + +console.log(because.match(/because/gi).length) + +const sentence = '%I $am@% a %tea@cher%, &and& I lo%#ve %te@a@ching%;. The@re $is no@th@ing; &as& mo@re rewarding as educa@ting &and& @emp%o@weri@ng peo@ple. ;I found tea@ching m%o@re interesting tha@n any ot#her %jo@bs. %Do@es thi%s mo@tiv#ate yo@u to be a tea@cher!? %Th#is 30#Days&OfJavaScript &is al@so $the $resu@lt of &love& of tea&ching\n' + +clean_sentence = sentence.replace(/\$|%|@|&|#|;/g, "") + +console.log(clean_sentence) + +let text = "He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month." + +let regex = /\d+/g; +let matches = text.match(regex) + +let totalIncome = 0; +for (let i = 0; i < matches.length; i++) { + totalIncome += parseInt(matches[i]); +} + +totalIncome *= 12; + +console.log('Total Annual Income:', totalIncome, 'euro'); \ No newline at end of file