diff --git a/1-js-basics/1-data-types/assignment.md b/1-js-basics/1-data-types/assignment.md index 55c3b06..4b9b100 100644 --- a/1-js-basics/1-data-types/assignment.md +++ b/1-js-basics/1-data-types/assignment.md @@ -1,5 +1,5 @@ -# Data Types Practice - -## Instructions - -Imagine you are building a shopping cart. Write some documentation on the data types that you would need to complete your shopping experience. How did you arrive at your choices? +- Strings: To store text-based information such as product names, categories, and user details. +- Numbers:To handle all quantities, prices, totals, and IDs. +- Boolean:To represent true/false conditions in the cart. +- Arrays:To store lists of related items, such as products in the cart. +- Objects:To represent structured data like a single product, user, or order. \ No newline at end of file diff --git a/1-js-basics/2-functions-methods/assignment.md b/1-js-basics/2-functions-methods/assignment.md index 4621399..24e8c2a 100644 --- a/1-js-basics/2-functions-methods/assignment.md +++ b/1-js-basics/2-functions-methods/assignment.md @@ -1,7 +1,22 @@ -# Fun with Functions +# Challenge +- method is something that belong to an object or a class. It is also defined within a class defination. +while function is something that can be defined any where and used anywhere. A method can only be used to manipulate or something related to it to a class or its objects +# assignment +``` +function funct1(a){ + console.log(a); +} +``` +- or it can be written in the following way -## Instructions +``` +function funct2(a){ + return a; +} +``` +- here is the function with defualt and normal parameters -Create different functions, both functions that return something and functions that don't return anything. - -See if you can create a function that has a mix of parameters and parameters with default values. +``` +function funct3(a=2,b){ + console.log(a+b); +} diff --git a/1-js-basics/3-making-decisions/assignment.md b/1-js-basics/3-making-decisions/assignment.md index 9c77e36..dfd37f0 100644 --- a/1-js-basics/3-making-decisions/assignment.md +++ b/1-js-basics/3-making-decisions/assignment.md @@ -1,25 +1,4 @@ # Operators - -## Instructions - -Play around with operators. Here's a suggestion for a program you can implement: - -You have a set of students from two different grading systems. - -### First grading system - -One grading system is defined as grades being from 1-5 where 3 and above means you pass the course. - -### Second grading system - -The other grade system has the following grades `A, A-, B, B-, C, C-` where `A` is the top grade and `C` is the lowest passing grade. - -### The task - -Given the following array `allStudents` representing all students and their grades, construct a new array `studentsWhoPass` containing all students who pass. - -> TIP, use a for-loop and if...else and comparison operators: - ```javascript let allStudents = [ 'A', @@ -31,4 +10,20 @@ let allStudents = [ ] let studentsWhoPass = []; +for (let i = 0; i < allStudents.length; i++) { +  let grade = allStudents[i]; +  if (typeof grade === "number") { +  if (grade >= 3) { +  studentsWhoPass.push(grade); +  } +  } + +  else if (typeof grade === "string") { +  if (grade === "A" || grade === "A-" || grade === "B" ||  +  grade === "B-" || grade === "C" || grade === "C-") { +  studentsWhoPass.push(grade); +  } +  } +} +console.log("Passing Students:", studentsWhoPass); ``` diff --git a/1-js-basics/4-arrays-loops/assignment.md b/1-js-basics/4-arrays-loops/assignment.md index 96d2170..ed717fb 100644 --- a/1-js-basics/4-arrays-loops/assignment.md +++ b/1-js-basics/4-arrays-loops/assignment.md @@ -1,7 +1,10 @@ # Loop an Array -## Instructions +``` +for(let i=0;i≤20;i++){ + if(i%3 == 0){ + console.log(i); + } +} +``` -Create a program that lists every 3rd number between 1-20 and prints it to the console. - -> TIP: use a for-loop and modify the iteration-expression