From 5b6df407c491201186bab619049107e42b3f94a9 Mon Sep 17 00:00:00 2001 From: adamascencio Date: Tue, 7 Feb 2023 10:02:35 -0800 Subject: [PATCH] exercise level2 complete --- solutions/day-01/countries.js | 13 +++++++++ solutions/day-01/index.html | 2 +- solutions/day-01/level1.js | 54 +++++++++++++++++++---------------- solutions/day-01/web_techs.js | 9 ++++++ 4 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 solutions/day-01/countries.js create mode 100644 solutions/day-01/web_techs.js diff --git a/solutions/day-01/countries.js b/solutions/day-01/countries.js new file mode 100644 index 0000000..8dd6abd --- /dev/null +++ b/solutions/day-01/countries.js @@ -0,0 +1,13 @@ +export const countries = [ + 'Albania', + 'Bolivia', + 'Canada', + 'Denmark', + 'Ethiopia', + 'Finland', + 'Germany', + 'Hungary', + 'Ireland', + 'Japan', + 'Kenya', +]; \ No newline at end of file diff --git a/solutions/day-01/index.html b/solutions/day-01/index.html index 21198b3..b45c2da 100644 --- a/solutions/day-01/index.html +++ b/solutions/day-01/index.html @@ -8,6 +8,6 @@

30 Days of React - Day 1

- + \ No newline at end of file diff --git a/solutions/day-01/level1.js b/solutions/day-01/level1.js index 0b191ca..99753b8 100644 --- a/solutions/day-01/level1.js +++ b/solutions/day-01/level1.js @@ -1,28 +1,7 @@ -// Exercises: Level 1 -const countries = [ - 'Albania', - 'Bolivia', - 'Canada', - 'Denmark', - 'Ethiopia', - 'Finland', - 'Germany', - 'Hungary', - 'Ireland', - 'Japan', - 'Kenya', -] +import { countries } from './countries.js'; +import { webTechs } from './web_techs.js'; -const webTechs = [ - 'HTML', - 'CSS', - 'JavaScript', - 'React', - 'Redux', - 'Node', - 'MongoDB', -] -// Exercises +// Exercises: Level 1 // 1. const arr = []; // 2. @@ -109,3 +88,30 @@ console.log('22. ', removeLastCompany); // 23. const removeAllCompanies = itCompanies.splice(0, itCompanies.length); console.log('23. ', removeAllCompanies); + +// Exercises: Level 2 +// 2. +let text = 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.' +text = text.replace(/[.,]/g, ''); +const words = text.split(' '); +console.log(text); +console.log(words); +console.log(words.length); +// 3. +const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']; +shoppingCart.unshift('Meat'); +shoppingCart.push('Sugar'); +const honeyIndex = shoppingCart.indexOf('Honey'); +shoppingCart.splice(honeyIndex, 1); +const teaIndex = shoppingCart.indexOf('Tea'); +shoppingCart.splice(teaIndex, 1, 'Green Tea'); +console.log(shoppingCart); +// 4. +countries.includes('Ethiopia') ? console.log('4. ETHIOPIA') : countries.push('Ethiopia'); +// 5. +webTechs.includes('Sass') ? console.log('5. Sass is a CSS preprocess') : webTechs.push('Sass'); +// 6. +const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux']; +const backEnd = ['Node', 'Express', 'MongoDB']; +const fullStack = frontEnd.concat(backEnd); +console.log(fullStack); diff --git a/solutions/day-01/web_techs.js b/solutions/day-01/web_techs.js new file mode 100644 index 0000000..8497982 --- /dev/null +++ b/solutions/day-01/web_techs.js @@ -0,0 +1,9 @@ +export const webTechs = [ + 'HTML', + 'CSS', + 'JavaScript', + 'React', + 'Redux', + 'Node', + 'MongoDB', +]; \ No newline at end of file