Skip to content

Commit 5e30c8c

Browse files
author
Ashfaq
committed
intermediate
1 parent 26ca522 commit 5e30c8c

File tree

10 files changed

+99
-23
lines changed

10 files changed

+99
-23
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.vscode/launch.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

KyleSimpson/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict"
2+
var anotherTeacher = function teacher() { console.log(teacher) }
3+
function makingBlockScope() {
4+
try {
5+
let name = "Ashfaq";
6+
var scope = "function scope"
7+
} catch (e) {
8+
console.log(scope)
9+
}
10+
console.log(scope)
11+
}
12+
13+
14+
makingBlockScope()
15+
var mobile = { brand: "vivo", modal: "v11 pro", }
16+
console.log(mobile);
17+
Object.freeze(mobile)
18+
mobile.color = "blue"
19+
console.log(mobile)

KyleSimpson/module.js

Whitespace-only changes.

KyleSimpson/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "kylesimpson",
3+
"version": "1.0.0",
4+
"description": "javaScript By kyle simpson https://static.frontendmasters.com/resources/2019-03-07-deep-javascript-v2/deep-js-foundations-v2.pdf ",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}

KyleSimpson/scope.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var anotherTeacher = function teacher() { console.log(teacher) }
2+
function makingBlockScope() {
3+
try {
4+
let name = "Ashfaq";
5+
var scope = "function scope"
6+
} catch (e) {
7+
console.log(scope)
8+
}
9+
console.log(scope)
10+
}
11+
12+
13+
makingBlockScope()
14+
var mobile = { brand: "vivo", modal: "v11 pro", }
15+
console.log(mobile);
16+
mobile.color = "blue"

app.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ g.setLanguage('es');
1212

1313
g.greet().log();
1414

15-
$('#login').click(function(){
16-
var loginGreetr = G$('ashfaq', 'ansari', 'en');
15+
$('#login').click(function () {
16+
var loginGreetr = G$('ashfaq', 'ansari', 'en');
1717
// hide login from the screen
1818
$('#logindiv').hide();
19-
loginGreetr.setLanguage($('#language').val( )).HTMLGreeting('#greeting', true).log()
20-
})
19+
loginGreetr.setLanguage($('#language').val()).HTMLGreeting('#greeting', true).log()
20+
})
21+

closures.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ function build3() {
7272

7373
var fs3 = build3();
7474

75-
fs3[0](); //3
76-
fs3[1](); //3
77-
fs3[2](); //3
75+
fs3[0](); //0
76+
fs3[1](); //1
77+
fs3[2](); //2
78+
79+
80+
// KYLE SIMPSON deep javascript //
81+
// closure is preservation of linkage of variable not value
82+
83+
var teacher = "kyle";
84+
85+
var myTeacher = function () {
86+
console.log(teacher)
87+
}
88+
89+
teacher = "Simpson"
90+
91+
myTeacher()

concurrentApiCalls.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const axios = require('axios');
22
let NewsIDs = [9224, 8917, 8952, 8884, 8887, 8869, 8958, 8940, 8908, 9005, 8873, 9671, 9067, 9055, 8865, 8881, 8872, 8955, 10403, 8903, 8928, 9125, 8998, 8901, 8902, 8907, 8894, 8870, 8878, 8980, 8934, 8943, 8876];
33

4+
console.log(workshopInstance)
45
module.exports = {
56
concurrentApiCalls: (function getNewsByID(IDs) {
67
// It will return and URL

index.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
const { concurrentApiCalls } = require("./concurrentApiCalls");
1+
const { concurrentApiCalls } = require("./concurrentApiCalls");
2+
function insertionSort(list) {
3+
const len = list.length
4+
for (let i = 1; i < len; i++) {
5+
if (list[i] < list[0]) {
6+
// move current element to the first position
7+
list.unshift(list.splice(i, 1)[0])
8+
}
9+
else if (list[i] > list[i - 1]) {
10+
// maintain element position
11+
continue
12+
}
13+
else {
14+
// find where element should go
15+
for (let j = 1; j < i; j++) {
16+
if (list[i] > list[j - 1] && list[i] < list[j]) {
17+
// move element
18+
list.splice(j, 0, list.splice(i, 1)[0])
19+
}
20+
}
21+
}
22+
}
23+
return list
24+
}
25+
26+
const list = [4, 2, 3, 1, 5]
27+
28+
const sorted = insertionSort(list)
29+
30+
console.log(sorted)

0 commit comments

Comments
 (0)