Skip to content

Commit 0e83ada

Browse files
committed
02_Basics done
1 parent 04aabe2 commit 0e83ada

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

02_Basics/function.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use strict";
2+
//Function
3+
Object.defineProperty(exports, "__esModule", { value: true });
4+
function addTwo(num) {
5+
return num + 2;
6+
}
7+
var sum = addTwo(5);
8+
console.log(sum);
9+
function getUpper(val) {
10+
var upper = val.toUpperCase();
11+
return "hello g ".concat(upper);
12+
// return 5; // give error
13+
}
14+
var returnFunc = getUpper("waseem");
15+
console.log(returnFunc);
16+
function signupUser(username, email, isLoggedIn) {}
17+
signupUser("wcoder547", "w@w.com", false);
18+
var loggedinUser = function (username, password, googleAccount) {
19+
if (googleAccount === void 0) {
20+
googleAccount = false;
21+
}
22+
return 12;
23+
};
24+
loggedinUser("wcoder547", 1122);
25+
var getHello = function (s) {
26+
return "";
27+
};
28+
getHello("s");
29+
var Hero = ["fahad", "talha", "waseem"];
30+
var count = [1, 2, 3, 4, 5, 6];
31+
Hero.forEach(function (hero) {
32+
return "Hero :".concat(hero);
33+
});
34+
count.forEach(function (val) {
35+
return val;
36+
});
37+
function consoleError(errMsg) {
38+
console.log("Error is :".concat(errMsg));
39+
return;
40+
}
41+
function handleError(err) {
42+
throw new Error(err);
43+
}

02_Basics/function.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//Function
2+
3+
function addTwo(num: number) {
4+
return num + 2;
5+
}
6+
let sum: number = addTwo(5);
7+
console.log(sum);
8+
9+
function getUpper(val: string): string {
10+
let upper = val.toUpperCase();
11+
return `hello g ${upper}`;
12+
// return 5; // give error
13+
}
14+
let returnFunc = getUpper("waseem");
15+
console.log(returnFunc);
16+
17+
function signupUser(username: string, email: string, isLoggedIn: boolean) {}
18+
signupUser("wcoder547", "w@w.com", false);
19+
20+
let loggedinUser = (
21+
username: string,
22+
password: number,
23+
googleAccount: boolean = false
24+
): number => {
25+
return 12;
26+
};
27+
28+
loggedinUser("wcoder547", 1122);
29+
30+
const getHello = (s: string): string => {
31+
return "";
32+
};
33+
getHello("s");
34+
35+
const Hero = ["fahad", "talha", "waseem"];
36+
const count = [1, 2, 3, 4, 5, 6];
37+
Hero.forEach((hero: string): string => {
38+
return `Hero :${hero}`;
39+
});
40+
count.forEach((val: number): number => {
41+
return val;
42+
});
43+
44+
function consoleError(errMsg: string): void {
45+
console.log(`Error is :${errMsg}`);
46+
return;
47+
}
48+
49+
function handleError(err: string): never {
50+
throw new Error(err);
51+
}
52+
export {};

02_Basics/myobject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("hello world");

02_Basics/myobject.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
console.log("hello world");
2+
3+
const user = {
4+
name: "waseem_akram",
5+
gmail: "w@w.com",
6+
isDeveloper: false,
7+
};
8+
9+
function createUser({ name: string, isPaid: boolean }) {}
10+
let newUser = { name: "waseemakram", isPaid: true };
11+
12+
createUser(newUser);
13+
14+
function getObject(): { name: string; price: number } {
15+
return { name: "waseem", price: 1122 };
16+
}
17+
18+
export {};

0 commit comments

Comments
 (0)