Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions 1-js-basics/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

# 1.Variables and Data Types

## Assignment
> For making a shopping cart I would first use String,int data types mainly.I might use array for some rare cases like including multiple items under one bigger group. Then would use boolean to know wheter the item is bought or no.
## Challenge
> Here when age=1; and Age=2; the java script treats both the variables as two different variable and returns false because both are different variables and 1!=2
### Gotchas
> 1. Another coommon type of gotcha is "==" vs "===" in cases like 12 == '12' it return true as javascript coerces them to same data type and compares the value but '===' strictly compares both the value and data type so in 12 === '12' it returns false
> 2. If we add a number to string then we end with string ,example 1+'1' then output would be like '11'.
> 3. NaN(Not a Number) is not equal to itself and if we use isNaN("") or isNaN([]) then javascript coerces them into number data type and then return true.
> 4. When new array is created it is created with empty items so we need to manually intialize it.
> 5. 0.1+0.2 !==0.3 as java using floating-point arithemetic so leads to precision errors.


# 2.functions-methods

## Assignment
> Function with no return:
```
function name(){
console.log("Sathvik");
}
name();
```
> Function with return:
```
function name(s){
return s;
}
name("Sathvik");
```
> Function with mixed parameters

```
function Details(name,age=0){
return {age,name};
}
Details("Sathvik");
Output:
Object { age: 0, name: "Sathvik" }
```
# 3.Making-decision

## Assingment

> Function performs set of tasks but method performs a set of tasks that are associated with an object.
```
const allStudents = [
'A',
'B-',
1,
4,
5,
2
]

let studentsWhoPass = [];
function pass(s){
if(typeof s =="number" && s>2){
studentsWhoPass.push(s);
}
else if(typeof s == "string" && s!== 'C-'){
studentsWhoPass.push(s)
}
}
allStudents.forEach(pass);
console.log(studentsWhoPass);
```
### Challenge
> Function with if .. else:
```
function check(s){
if(s === 200){
return 1
}
else{
return 0
}
}
check(150)
```
>Function with ternary operator
```
let a=200
const c = a === 200 ? 1:0;
console.log(c);
```
# 4.Arrays-loops

### Assignment
```

let arr=[]
for(let i=1;i<20;i++){
if(i%3 === 0){
arr.push(i);
}…
```
### Challenge

```
let arr=[1,23,4,45,6,7,8];
arr.forEach((element)=>console.log(element));
```
36 changes: 36 additions & 0 deletions 4-bank-project/bank-project-solution/Solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 1-template-route

## Assignment
```
Used "document.title = route.templateID" here to assign title the name of template.
Then used console.log() if templateID is dashboard
```

## Challenge
```
Created a new template named "credit" in html and then added a new route and gave it a template id.
```
# 2-forms
##Assignment
```
In this created a division named "loginerror" and then in javascript used if condition to check if data has any error then return that error using "updateElement"
```

##Challenge
```
Did some simple styling ,code is uploaded.
```
# 3-data

##Assignment
```
Added comments here and there.Then created a const which stores the url and used tht constant
```
##Challenge
```
tr:nth-child() used this method to color rows alternately and used hover,then added "add transaction" box in html with hover
```
# 4-bank-project
```
Added a transaction box by creating a dialog box and form in html. Then used the same method as how we did for register. That is fetching the api and then adding response to it. Then mannualy adding the inputted data and manually updating the data.Used setTimeout as it was causing errors
```
Loading