From b5716fc91de491a13400b6c65401fed66e83f1b6 Mon Sep 17 00:00:00 2001 From: Long Vay Date: Tue, 8 Aug 2023 17:34:36 -0700 Subject: [PATCH] started level 2 --- solutions/day-01/countries.js | 15 +++++++++++++++ solutions/day-01/level2.js | 35 +++++++++++++++++++++++++++++++++++ solutions/day-01/web_tech.js | 11 +++++++++++ 3 files changed, 61 insertions(+) create mode 100644 solutions/day-01/countries.js create mode 100644 solutions/day-01/level2.js create mode 100644 solutions/day-01/web_tech.js diff --git a/solutions/day-01/countries.js b/solutions/day-01/countries.js new file mode 100644 index 0000000..2b703a1 --- /dev/null +++ b/solutions/day-01/countries.js @@ -0,0 +1,15 @@ +const countries = [ + 'Albania', + 'Bolivia', + 'Canada', + 'Denmark', + 'Ethiopia', + 'Finland', + 'Germany', + 'Hungary', + 'Ireland', + 'Japan', + 'Kenya', + ] + +export { countries }; \ No newline at end of file diff --git a/solutions/day-01/level2.js b/solutions/day-01/level2.js new file mode 100644 index 0000000..ed6f90b --- /dev/null +++ b/solutions/day-01/level2.js @@ -0,0 +1,35 @@ +import { countries } from "./countries"; +// import { webTechs } from "./web_tech"; + +/** + * EXERCISE: Level 2 + */ + +// 1. Create a separate countries.js file and store the countries array into this file, +// creata a separate file web_tech.js and store the web Techs Array into this file. +// Access both file in main,js file + +// 2. First remove all the punctuations and change the string to array and count the number of words in the array +let text = 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'; +let words = text.split(".").join("").split(" "); +// console.log(words); +// console.log(words.length); + +// 3. In the following shopping cart add, remove, edit items +const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']; +/** + * - add 'Meat' int eh beginning of your shopping cart if it has not been already added + * - add Sugar at the end of your shopping car if it has not been already added + * - remove 'Honey' if you are allergic to honey + * - modify Tea to 'Green Tea' + */ + +shoppingCart.unshift('Meat') +shoppingCart.push('Sugar'); +shoppingCart.splice(shoppingCart.indexOf('Honey'), 1); +shoppingCart[shoppingCart.indexOf('Tea')] = 'Green Tea'; +console.log(shoppingCart); + +// 4. In countries array check if 'Ethiopia' exist in the array if it exists print 'ETHIOPIA'. If it does not exist add +// to the countries list +console.log(countries) \ No newline at end of file diff --git a/solutions/day-01/web_tech.js b/solutions/day-01/web_tech.js new file mode 100644 index 0000000..2b3133a --- /dev/null +++ b/solutions/day-01/web_tech.js @@ -0,0 +1,11 @@ +const webTechs = [ + 'HTML', + 'CSS', + 'JavaScript', + 'React', + 'Redux', + 'Node', + 'MongoDB', + ]; + + export { webTechs }; \ No newline at end of file