From a94410431db83d857b0da26b1ecb41dc0af06204 Mon Sep 17 00:00:00 2001 From: Khushal Date: Sat, 22 Feb 2025 00:13:37 +0530 Subject: [PATCH 1/3] added solution.md in each sub topic --- 1-js-basics/1-data-types/solution.md | 39 +++++++++++++++++++++ 1-js-basics/2-functions-methods/solution.md | 23 ++++++++++++ 1-js-basics/3-making-decisions/solution.md | 22 ++++++++++++ 1-js-basics/solution.md | 26 ++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 1-js-basics/1-data-types/solution.md create mode 100644 1-js-basics/2-functions-methods/solution.md create mode 100644 1-js-basics/3-making-decisions/solution.md create mode 100644 1-js-basics/solution.md diff --git a/1-js-basics/1-data-types/solution.md b/1-js-basics/1-data-types/solution.md new file mode 100644 index 0000000..435f8fc --- /dev/null +++ b/1-js-basics/1-data-types/solution.md @@ -0,0 +1,39 @@ +#H1 Review and Self Study: +```javascript +const arr = ["hi",how"","you"]; +const first = arr.pop(); +console.log(first); // this will not only remove last element but it also returns that last element +const last = arr.shift(); +console.log(last); // same goes for this too it not only removes first element but also reeturns it + +``` +```javascript +const arr = ["hi","how","you"]; +const first = arr.slice(0, 1);// first will store hi +const rem = arr.slice(1); // rem will store how and you +``` + + + +#h2 Assignment +When we are building a shopping cart, we need many things which include user name, his password, an array of all items which contain objects which probably include a name of item and number of such items
> + + +

+first one is username which is a string +

+

+next is alpha nemeric password which is again a string +

+

+an array of all items in the cart +

+

+an object in the follow whose object's format is something like following +``` +name : +value: +``` +
+where if a new item is introduced to cart a new object is created and value will be number of that items thrown into cart +

diff --git a/1-js-basics/2-functions-methods/solution.md b/1-js-basics/2-functions-methods/solution.md new file mode 100644 index 0000000..993c181 --- /dev/null +++ b/1-js-basics/2-functions-methods/solution.md @@ -0,0 +1,23 @@ +#H1 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 +

+ + +#h1 Self learing +

=> is used to skip word function and skip a lot of syntax

+ +#h1 +```javascript +function funct1(a){ + console.log(a); +} +``` +
or it can be written the following way + +```javascript +function funct2(a){ + return a; +} +``` + diff --git a/1-js-basics/3-making-decisions/solution.md b/1-js-basics/3-making-decisions/solution.md new file mode 100644 index 0000000..1469678 --- /dev/null +++ b/1-js-basics/3-making-decisions/solution.md @@ -0,0 +1,22 @@ +#h1 Challenge +```javascript +if(x>5){ + print(x) +}else{ + print("no") +} + +with ternery operator--> + +let var = (x>5)? print(5) : print("no") +``` + +#h1 Assignment +``` + +studentsWhoPass=[]; +for(let i=0, i<6, i++){ + if !(allStudents[i]=="C-" || allStudents[i]==2 || allStudents[i]==1) + {studentsWhoPass.push(allStudents[i]);} +} + diff --git a/1-js-basics/solution.md b/1-js-basics/solution.md new file mode 100644 index 0000000..2cdd645 --- /dev/null +++ b/1-js-basics/solution.md @@ -0,0 +1,26 @@ +# Challenge + + +```javascript +const items = ["item1", "item2", "item3"]; +const copyItems = []; + +for (let i = 0; i < items.length; i++) { + copyItems.push(items[i]); +} + +items.forEach((item) => { + copyItems.push(item); +}); +``` + +```javascript +for(let i = 1, i <= 20,i++){ + if (i%3==0){console.log(i);} +} +``` + + + + + From 995fc5b59f4ee704bddae47004b2bd81eb5ebeab Mon Sep 17 00:00:00 2001 From: Khushal Date: Sat, 22 Feb 2025 21:39:07 +0530 Subject: [PATCH 2/3] adding final version of issue-1 --- 1-js-basics/1-data-types/solution.md | 35 ++++++++++----------- 1-js-basics/2-functions-methods/solution.md | 17 +++++++--- 1-js-basics/3-making-decisions/solution.md | 17 +++++----- 1-js-basics/4-arrays-loops/solution.md | 32 +++++++++++++++++++ 4 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 1-js-basics/4-arrays-loops/solution.md diff --git a/1-js-basics/1-data-types/solution.md b/1-js-basics/1-data-types/solution.md index 435f8fc..289f3dc 100644 --- a/1-js-basics/1-data-types/solution.md +++ b/1-js-basics/1-data-types/solution.md @@ -1,4 +1,5 @@ -#H1 Review and Self Study: +

Review and Self Study

+ ```javascript const arr = ["hi",how"","you"]; const first = arr.pop(); @@ -13,27 +14,23 @@ const first = arr.slice(0, 1);// first will store hi const rem = arr.slice(1); // rem will store how and you ``` +

Challenge

+

+ since age points 1 and Age points 2, age==Age returns false. other than this, using === compares not only values but also its data types +

-#h2 Assignment -When we are building a shopping cart, we need many things which include user name, his password, an array of all items which contain objects which probably include a name of item and number of such items
> + +

Assignment

+When we are building a shopping cart, we need many things which include user name, his password, an array of all items which contain objects which probably include a name of item and number of such items

-first one is username which is a string -

-

-next is alpha nemeric password which is again a string -

-

-an array of all items in the cart -

-

-an object in the follow whose object's format is something like following -``` -name : -value: -``` -
-where if a new item is introduced to cart a new object is created and value will be number of that items thrown into cart +

+ diff --git a/1-js-basics/2-functions-methods/solution.md b/1-js-basics/2-functions-methods/solution.md index 993c181..db4a824 100644 --- a/1-js-basics/2-functions-methods/solution.md +++ b/1-js-basics/2-functions-methods/solution.md @@ -1,23 +1,30 @@ -#H1 Challenge +

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

-#h1 Self learing -

=> is used to skip word function and skip a lot of syntax

-#h1 + +

assignment

+ ```javascript function funct1(a){ console.log(a); } ``` -
or it can be written the following way +or it can be written the following way ```javascript function funct2(a){ return a; } ``` +here is a function with default and normal parameters + +```javascript +function funct3( a =2 , b){ + console.log(a+b); +} +``` diff --git a/1-js-basics/3-making-decisions/solution.md b/1-js-basics/3-making-decisions/solution.md index 1469678..6440ce0 100644 --- a/1-js-basics/3-making-decisions/solution.md +++ b/1-js-basics/3-making-decisions/solution.md @@ -1,22 +1,25 @@ -#h1 Challenge +

Challenge

+ ```javascript if(x>5){ print(x) }else{ print("no") } +``` +with ternery operator, -with ternery operator--> - +```javascript let var = (x>5)? print(5) : print("no") ``` -#h1 Assignment -``` +

Assignment

+```javascript studentsWhoPass=[]; for(let i=0, i<6, i++){ - if !(allStudents[i]=="C-" || allStudents[i]==2 || allStudents[i]==1) - {studentsWhoPass.push(allStudents[i]);} + if !(allStudents[i]=="C-" || allStudents[i]==2 || allStudents[i]==1){ + studentsWhoPass.push(allStudents[i]); + } } diff --git a/1-js-basics/4-arrays-loops/solution.md b/1-js-basics/4-arrays-loops/solution.md new file mode 100644 index 0000000..3354659 --- /dev/null +++ b/1-js-basics/4-arrays-loops/solution.md @@ -0,0 +1,32 @@ +# Review & Self Study + + +```javascript +const items = ["item1", "item2", "item3"]; +const copyItems = []; + +for (let i = 0; i < items.length; i++) { + copyItems.push(items[i]); +} + +items.forEach((item) => { + copyItems.push(item); +}); +``` +# Challenge +```javascript +array=[1,2,3,4] +array.forEach((element) => console.log(element)); +``` + +# Assignment +```javascript +for(let i = 1, i <= 20,i++){ + if (i%3==0){console.log(i);} +} +``` + + + + + From 06e113939c9fd3e6a41c6cdc152e34a812e9d144 Mon Sep 17 00:00:00 2001 From: Khushal Date: Sat, 22 Feb 2025 22:04:22 +0530 Subject: [PATCH 3/3] adding final version of issue-1 --- 1-js-basics/solution.md | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 1-js-basics/solution.md diff --git a/1-js-basics/solution.md b/1-js-basics/solution.md deleted file mode 100644 index 2cdd645..0000000 --- a/1-js-basics/solution.md +++ /dev/null @@ -1,26 +0,0 @@ -# Challenge - - -```javascript -const items = ["item1", "item2", "item3"]; -const copyItems = []; - -for (let i = 0; i < items.length; i++) { - copyItems.push(items[i]); -} - -items.forEach((item) => { - copyItems.push(item); -}); -``` - -```javascript -for(let i = 1, i <= 20,i++){ - if (i%3==0){console.log(i);} -} -``` - - - - -