Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb39bda5

Browse files
Update README.md
Complete Assignment of JavaScript course
1 parent1e42568 commitb39bda5

File tree

1 file changed

+124
-36
lines changed

1 file changed

+124
-36
lines changed

‎README.md‎

Lines changed: 124 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
```js
1010
let languages="java javaScript python cSharp";
1111
let result=languages.lastIndexOf("S");
12-
console.log(result)
12+
console.log(result)
1313
```
1414
**Question 4:** Guess the**Output** and Explain Why?
1515

1616
```js
1717
let variable="hello programmers";
1818
let result=Number(variable);
19-
console.log(result);
19+
console.log(result);
2020
```
2121
**Question 5:** Guess the**Output** and Explain Why?
2222
```js
2323
let num1=32;
2424
let num2="32";
2525
let result1= num1!== num2;
2626
let result2= num1!= num2;
27-
console.log(result1,result2);
27+
console.log(result1,result2);
2828
```
2929

3030
**Question 6:** Guess the**Output** and explain Why?
@@ -39,22 +39,22 @@ console.log(result);
3939
let num1=2;
4040
let num2=5;
4141
let result= num1**num2*2;
42-
console.log(result);
42+
console.log(result);
4343
```
4444
**Question 8:** Guess the**Output** and Explain Why?
4545
```js
4646
let num1= [1,2,4,5];
4747
let num2= [6,5,8,0];
4848
let result=num1.concat(num2);
49-
console.log(result)
49+
console.log(result)
5050
```
5151
**Question 9:** Guess the**Output** and Explain Why?
5252
```js
5353
let a=5;
5454
let b=7;
5555
let c=8;
5656
let result= a<b>c;
57-
console.log(result)
57+
console.log(result)
5858
```
5959
**Question 10:** If your state split into**four** equal parts such that in each part there are**1/4** number of people live. You have to find How many people would live in each part?
6060

@@ -80,7 +80,7 @@ else{
8080
```js
8181
let i=0;
8282
for(i;i<5;i++){
83-
console.log(i);
83+
console.log(i);
8484
}
8585
```
8686
**Question 3:** Write a simple**Program** in which You have to print first**10** number in**descending** order?
@@ -122,7 +122,7 @@ Example
122122
functionaddition(num1,num2){
123123
return num1+ num2;
124124
}
125-
console.log(addition());//You are not allowed to modify this line any more
125+
console.log(addition());//You are not allowed to modify this line any more
126126
```
127127

128128
**Question 4:** Identify which**type** of value passed below into the function**greet()**
@@ -134,7 +134,7 @@ age:25
134134
}
135135
functiongreet(person){
136136
person.name=`Mr${person.name}`
137-
console.log(`Welcome${person.name}`)
137+
console.log(`Welcome${person.name}`)
138138
}
139139
greet(person)
140140
```
@@ -161,7 +161,7 @@ and so on.
161161
```js
162162
letarrowFunction= (name="Coders")=> {`Welcome${name}`};
163163

164-
console.log(arrowFunction("Programmers"));
164+
console.log(arrowFunction("Programmers"));
165165
```
166166

167167
##Chapter 4 (Objects)
@@ -185,8 +185,8 @@ model:2021,
185185
company:"Toyota"
186186
}
187187
let carColor="Blue";
188-
console.log(car[carColor]);
189-
console.log(car.carColor);
188+
console.log(car[carColor]);
189+
console.log(car.carColor);
190190
```
191191
**Question 4:** Create a method**describeCar** inside*car* object in which you have to print like this in console using template literals
192192

@@ -234,7 +234,7 @@ bookMethod("john",8754);
234234
```js
235235
let arr= [1,2,3,4];
236236
for(let elemin arr){
237-
console.log(elem);
237+
console.log(elem);
238238
}
239239
```
240240

@@ -254,8 +254,8 @@ console.log(elem);
254254
**JavaScript**
255255
```js
256256
let content=document.getElementById("content")
257-
console.log(content.innerHTML)
258-
console.log(content.innerText)
257+
console.log(content.innerHTML)
258+
console.log(content.innerText)
259259
```
260260

261261

@@ -287,9 +287,9 @@ e.preventDefault();
287287
let password=inputPassword.value;
288288
let result=requiredPasswordPattern.test(password);
289289
if(result==true){
290-
console.log("Your password validated successfully")
290+
console.log("Your password validated successfully")
291291
}else{
292-
console.log("try again with new password")
292+
console.log("try again with new password")
293293
}
294294
})
295295
```
@@ -403,7 +403,7 @@ let nums = [16,17,18,28,22];
403403
let currentDate=newDate();
404404
let result1=currentDate.getDay();
405405
let result2=currentDate.getDate();
406-
console.log(result1,result2)
406+
console.log(result1,result2)
407407
```
408408

409409
##Chapter 9 (Local Storage)
@@ -435,11 +435,12 @@ class.
435435
**Question 3:** Guess the**Output** And Explain Why?
436436
```js
437437
functionPerson(name){
438-
this.name= name;
438+
this.name= name;
439439
}
440440
let me=newPerson("John");
441-
console.log(me.__proto__==Person.prototype);
442-
console.log(me.__proto__.__proto__==Object.prototype);
441+
442+
console.log(me.__proto__==Person.prototype);
443+
console.log(me.__proto__.__proto__==Object.prototype);
443444

444445
```
445446

@@ -465,18 +466,20 @@ class Car = {
465466

466467
```js
467468
functionPerson(name,age){
468-
this.name= name;
469-
this.age= age;
470-
this.brainMethod=function(){
471-
console.log("This is brain method of Person")
469+
470+
this.name= name;
471+
this.age= age;
472+
this.brainMethod=function(){
473+
console.log("This is brain method of Person")
472474
}
473475
}
474-
Person.heartMethod=function(){
475-
console.log("This is heart method of Person");
476+
Person.heartMethod=function(){
477+
console.log("This is heart method of Person");
476478
}
477479
let me=newPerson("john",34);
478-
me.brainMethod();
479-
me.heartMethod();
480+
481+
me.brainMethod();
482+
me.heartMethod();
480483
```
481484

482485
**Question 7:** Create a new class**Animal** (which will be child class) inherited from**Person** class. In Addition in**Animal** class Add some additional properties like**breedType** and**animalFamily**.(catFamily, dogFamily)
@@ -489,10 +492,88 @@ class Car {
489492
}
490493
}
491494
let car=newCar();
492-
console.log(Car.prototype.isPrototypeOf(Car));
493-
console.log(Car.prototype.isPrototypeOf(car));
495+
console.log(Car.prototype.isPrototypeOf(Car));
496+
console.log(Car.prototype.isPrototypeOf(car));
497+
```
498+
##Chapter 11( Async & Await )
499+
500+
###Assignments
501+
502+
**Question 1:** Guess the**Output** And Explain Why?
503+
**Html Code**
504+
505+
506+
```html
507+
<!DOCTYPE html>
508+
<htmllang="en">
509+
<head>
510+
<metacharset="UTF-8">
511+
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
512+
<metaname="viewport"content="width=device-width, initial-scale=1.0">
513+
<title>JavaScript-CoderDost</title>
514+
<style>
515+
</head>
516+
<body>
517+
<div id="content">
518+
519+
<h2 id = "heading"></h2>
520+
521+
</div>
522+
<script defer src = "./script.js"></script>
523+
</script>
524+
</body>
525+
</html>
526+
```
527+
**JS Code**
528+
529+
```js
530+
async function greeting() {
531+
letmyPromise =newPromise(function(resolve) {
532+
setTimeout(function() {resolve("IloveProgramming !!");}, 2000);
533+
});
534+
document.getElementById("heading").innerHTML = await myPromise;
535+
}
536+
greeting();
494537
```
495538
539+
**Question 2:** Find the**Logical Error** in belowcode. And How can we solve them with**callback** function approach?
540+
541+
```js
542+
543+
const movies = [
544+
{ title: `Movie 1`},
545+
{ title: `Movie 2` }
546+
]
547+
548+
function getMovies(){
549+
setTimeout(() => {
550+
movies.forEach((movie,index) => {
551+
console.log(movie.title)
552+
})
553+
}, 1000);
554+
}
555+
556+
function createMovies(movie){
557+
setTimeout(() => {
558+
movies.push(movie)
559+
}, 2000);
560+
}
561+
562+
getMovies();
563+
564+
565+
createMovies({title: `Movie3`} )
566+
```
567+
568+
**Question 3:** What are the**three** possible State of any promise?
569+
570+
**Question 4:** Solve**Question 2** again But thistime with the help of**promise**
571+
572+
**Question 5:** Nowre-factor**Question 2** with the help of**async-await** keyword?
573+
574+
**Question 6:** Statuscode starting with**300** represent which type of message/error?
575+
576+
496577
## Chapter 12 (Modern Operators)
497578
498579
### Assignments
@@ -502,7 +583,7 @@ console.log(Car.prototype.isPrototypeOf(car));
502583
```js
503584
let arr = [3,4,5,7,98,0];
504585
let [a,b,,c] = arr;
505-
console.log(a,b,c);
586+
console.log(a,b,c);
506587
```
507588
508589
**Question 2:** Guess the**Output** And Explain Why?
@@ -521,7 +602,7 @@ weight:70
521602
}
522603
523604
let {name:objName,age} = obj;
524-
console.log(name,age);
605+
console.log(name,age);
525606
```
526607
527608
**Question 4:** You have given an array of**nums**.Create**shallow** copy of that array and store them in another**variable**
@@ -549,7 +630,7 @@ console.log(result);
549630
**Question 7:** You have given anobject as below. You have to check wheather**physics** is the subject of that student or not, if true find the**score** of**physics** subject using**optional chaining**
550631
551632
```js
552-
let student= {
633+
let student = {
553634
Math:{
554635
score:75,
555636
},
@@ -563,12 +644,19 @@ score:85,
563644
```js
564645
let nums = [2,3,4,5,6];
565646
for(let key of nums) {
566-
console.log(key)
647+
console.log(key)
567648
}
568649
```
569650
570-
651+
## Chapter 13 (Modern Tooling)
571652
653+
### Assignments
654+
655+
**Question 1:** You have given scenario. You are in**script.js** And in same directory there is another file**products.js**. In**products.js** there are two methods called**createProduct** and**deleteProduct**
656+
657+
write an**import** and**export** statement properly in order to import these two methods from**products.js** file into the**script.js**
572658
573659
660+
**Question 2** Now**export** only one method**createProduct** using**default** export statement?
574661
662+
**Question 3:** In**importing** statement how can we**customize**/**change** the name of **function** we are importing?

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp