diff --git a/solution/day-01/level3.js b/solution/day-01/level3.js new file mode 100644 index 0000000000..61e7d508e5 --- /dev/null +++ b/solution/day-01/level3.js @@ -0,0 +1,45 @@ + +//Q1 +const ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24] ; +const sorted = ages.sort(( a,b)=> a-b); +let maxAge = sorted[sorted.length-1]; +let minAge = sorted[0]; + +// Median age + +const mid = Math.floor(ages.length/2); + + if(mid%2===0){ + const median = (ages[mid-1]+ages[mid])/2; + return median; + } + else{ + const medianNun = arr[mid]; + return medianNun; + } + +// average age +let sum = 0; + +for(let i=0;i1){ + filteredCompanies.push(company); + } +} +console.log(filteredCompanies); + +//Q15 +companies.sort((a,b)=> a -b); + +//Q16 +companies.reverse(); + +//Q17 +companies.slice(0,3); + +//Q18 +companies.slice(-3); + +//Q19 +const middle = Math.floor(companies.length / 2); +let slicedArray ; +if(companies.length %2 === 0){ + slicedArray = companies.slice(middle -1,middle+1) +} +else{ + slicedArray = companies[middle]; +} +console.log(slicedArray); + +//Q20 + +companies.shift(); + +//Q21 +const middleIndex = Math.floor(companies.length/2); + +const removedElement = companies.splice(middleIndex,1); + +//Q22 + +companies.pop(); + +//Q23 +companies.splice(0,companies.length); + + + diff --git a/solutions/day-01/level2/countries.js b/solutions/day-01/level2/countries.js new file mode 100644 index 0000000000..507c597771 --- /dev/null +++ b/solutions/day-01/level2/countries.js @@ -0,0 +1,15 @@ +const countries = [ + 'Albania', + 'Bolivia', + 'Canada', + 'Denmark', + 'Ethiopia', + 'Finland', + 'Germany', + 'Hungary', + 'Ireland', + 'Japan', + 'Kenya', + ] + + export default countries; \ No newline at end of file diff --git a/solutions/day-01/level2/main.js b/solutions/day-01/level2/main.js new file mode 100644 index 0000000000..e6e0b423d7 --- /dev/null +++ b/solutions/day-01/level2/main.js @@ -0,0 +1,54 @@ +// level 2 solutions +//Q1 +import countries from "./countries"; +import webTechs from "./web_techs"; + + +//Q2 +let text = + 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.' + +const words = sentence.replace(/[^\w\s]/g,''); +const wordsArray = words.split(" "); +const wordCount = wordsArray.length; +console.log(wordsArray) +console.log(wordCount); + +//Q3 +const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']; +shoppingCart.unshift("Meat"); +if(shoppingCart.indexOf("Sugar")===-1){ + shoppingCart.push("Sugar"); +} + +const honeyIndex = 3; +shoppingCart.splice(3,1); +shoppingCart[2]="Green Tea"; + +//Q4 + + +if(countries.indexOf("Ethiopia")===-1){ + countries.push("Ethiopia"); +} +else{ + console.log("ETHIOPIA"); +} + +//Q5 + +if(webTechs.indexOf("Sass")===-1){ + webTechs.push("Sass"); + console.log(webTechs); +} +else{ + console.log("Sass is CSS preprocess"); +} + +//Q6 +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/level2/solutions.js b/solutions/day-01/level2/solutions.js new file mode 100644 index 0000000000..581c0270d3 --- /dev/null +++ b/solutions/day-01/level2/solutions.js @@ -0,0 +1,24 @@ +//Q2 +let text = + 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.' + +const words = sentence.replace(/[^\w\s]/g,''); +const wordsArray = words.split(" "); +const wordCount = wordsArray.length; +console.log(wordsArray) +console.log(wordCount); + +//Q3 +const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']; +shoppingCart.unshift("Meat"); +if(shoppingCart.indexOf("Sugar")===-1){ + shoppingCart.push("Sugar"); +} + +const honeyIndex = 3; +shoppingCart.splice(3,1); +shoppingCart[2]="Green Tea"; + +//Q4 + + diff --git a/solutions/day-01/level2/web_techs.js b/solutions/day-01/level2/web_techs.js new file mode 100644 index 0000000000..6ed7a0ade9 --- /dev/null +++ b/solutions/day-01/level2/web_techs.js @@ -0,0 +1,10 @@ +const webTechs = [ + 'HTML', + 'CSS', + 'JavaScript', + 'React', + 'Redux', + 'Node', + 'MongoDB', + ] +export default webTechs; \ No newline at end of file diff --git a/solutions/day-02/exercises.js b/solutions/day-02/exercises.js new file mode 100644 index 0000000000..9c558e357c --- /dev/null +++ b/solutions/day-02/exercises.js @@ -0,0 +1 @@ +. diff --git a/solutions/day-02/exercises.txt b/solutions/day-02/exercises.txt new file mode 100644 index 0000000000..1f94d7f299 --- /dev/null +++ b/solutions/day-02/exercises.txt @@ -0,0 +1,41 @@ +1 .what is React? +-------------- +1. what is React? + +--React is a JavaScript library for building a reusable user interface(UI). It was initially released on May 29, 2013. +React makes creating UI components very easy + +2. what is library? + +--- library is a collection of pre-written code and resources that provide specific functionality and can be reused in different projects. A library typically consists of a set of functions, classes, or modules that encapsulate specific tasks or features, making it easier for developers to incorporate that functionality into their own applications without having to write everything from scratch. + +3.what is component? + +---In React, a component is a reusable and self-contained building block for building user interfaces. Components are the fundamental units of a React application, and they can be thought of as custom HTML elements that encapsulate their own functionality, state, and rendering logic. + +4. what is a singlepage application? + +---A Single-Page Application (SPA) is a web application that loads and operates within a single HTML page. Instead of navigating to different pages by requesting new HTML documents from the server, a single-page application dynamically updates the existing page by manipulating the Document Object Model (DOM) in response to user interactions. + +5.what is the latest version of React? +---- 17.02 + +6.What is DOM? + +DOM stands for Document Object Model. It is a programming interface for web documents, representing the structure and content of an HTML or XML document as a tree-like structure. The DOM represents the web page in a way that allows programming languages, like JavaScript, to interact with and manipulate the content, structure, and style of the document. + +7.What is React Virtual DOM? + +React Virtual DOM (Virtual Document Object Model) is a concept and technique used by React to optimize the rendering performance of web applications. It is a lightweight and efficient representation of the actual DOM that React uses to track and manage changes to the user interface. + +8.What does a web application or a website(composed of) have? + +A web application or website is composed of various components,that work together to deliver the desired functionality and user experience. Here are some key components commonly found in a web application or website: + +User Interface (UI): The user interface encompasses the visual and interactive elements of the application or website that users interact with. It includes components such as menus, buttons, forms, images, and other visual elements that facilitate user interaction. + +HTML/CSS: HTML (Hypertext Markup Language) and CSS (Cascading Style Sheets) are the foundational technologies used to structure and style web pages. HTML defines the structure and content of the page, while CSS is used to define the visual presentation and layout of the elements. + +JavaScript: JavaScript is a powerful scripting language that runs in the browser and enables dynamic interactivity and functionality on web pages. It is commonly used to handle user interactions, perform client-side validation, manipulate the DOM, make asynchronous requests to servers (AJAX), and implement various features and behaviors. + +Backend: The backend of a web application consists of server-side technologies and infrastructure responsible for processing requests, handling business logic, and interacting with \ No newline at end of file