Skip to content

Commit 2fe15cd

Browse files
Add files via upload
1 parent 7bbef26 commit 2fe15cd

File tree

3 files changed

+165
-0
lines changed

3 files changed

+165
-0
lines changed

LearnJS2/index.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewort" content="width=device-width, initial-scale=1.0">
6+
<meta htt-equiv="X-UA-Comatible" content="ie=edge">
7+
<title>Learn Js</title>
8+
</head>
9+
<body>
10+
<h1 id="para">Javascript</h1>
11+
<!-- Canvas Tag -->
12+
<!-- <canvas id="myCanvas"> Your browser does not support the HTML5 canvas
13+
tag.</canvas>
14+
15+
<script>
16+
var canvas = document.getElementById("myCanvas");
17+
var ctx = canvas.getContext("2d");
18+
ctx.fillStyle = "#FF0000";
19+
ctx.fillRect(0, 0, 80, 80);
20+
</script> -->
21+
<!-- JSON
22+
<script>
23+
let students = `[
24+
{
25+
"name": "Subham",
26+
"age":20,
27+
"height": 170
28+
29+
},
30+
31+
32+
{
33+
"name":"Shekhar",
34+
"age":19,
35+
"height":168
36+
37+
}
38+
39+
]`
40+
console.log(JSON.parse(students)[0].age);
41+
</script>
42+
-->
43+
44+
<script src="script.js"></script>
45+
46+
</body>
47+
</html>

LearnJS2/script.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//hello
2+
// console.log("hello!")
3+
4+
/*
5+
let age = prompt ("What is your age?")
6+
7+
document.getElementById('para').innerHTML = age;
8+
9+
function returnName(){
10+
let yourname = prompt("Type your name")
11+
console.log("Hello "+yourname)
12+
}
13+
returnName()
14+
15+
let sum = function(a,b) {
16+
return console.log(a + b)
17+
18+
}
19+
sum(2,5)
20+
21+
22+
let num = 0
23+
24+
while (num < 20) { //while loop
25+
num += 2;
26+
console.log(num)
27+
}
28+
*/
29+
/*
30+
let Fruits = 'apple\nbanana\ngrapes' //new line
31+
console.log(Fruits)
32+
33+
let name = 'subhamghimire,shekhar,nepal'
34+
console.log(name.indexOf('m'))
35+
console.log(name.slice(3,7))
36+
console.log(name.replace('sub','she'))
37+
console.log(name.toUpperCase(name))
38+
39+
console.log(name.split(',')) //split by comma
40+
console.log(name.split(''))//split by character
41+
*/
42+
/*
43+
let name = ['subham','shekhar','nepal']
44+
45+
console.log(name[0]) //access values at index
46+
47+
//array common methods
48+
console.log('to string', name.toString())
49+
console.log(name.join('*'))
50+
//push , pop , append,shift,unshift etc stuffs
51+
52+
console.log(name.push('hetauda'),name)
53+
54+
name[4] = 'new city'//same as push
55+
console.log(name)
56+
57+
console.log(name.pop())//remove last element from list
58+
console.log(name.shift()) //remove first element from list
59+
console.log(name.unshift('ktm')) //add element to first of an array
60+
61+
//sort
62+
let numbers = [1,3,66,7,2,3,4,89,55,0]
63+
console.log(numbers.sort(function(a,b){return a-b}))//sorted in ascending order
64+
console.log(numbers.sort(function(a,b){return b-a}))//sorted in descending order
65+
66+
//store in an empty array
67+
let emptyArray = new Array();
68+
for (let num = 0; num < 10; num++) {
69+
emptyArray.push(num)
70+
}
71+
console.log(emptyArray);
72+
73+
*/
74+
/*
75+
//object in js
76+
let info = {
77+
firstName : 'Subham',
78+
lastName : 'Ghimire',
79+
birthYear : 1999,
80+
friends : ['James','Mark','bob','Mary'],
81+
job : 'developer',
82+
isMarried : false,
83+
calcAge : function() {
84+
this.age = 2019 - this.birthYear;
85+
}
86+
};
87+
88+
//var age = console.log(info.calcAge());
89+
info.calcAge()
90+
console.log(info);
91+
92+
*/
93+
//6 --> weekend Saturday
94+
// switch(2){
95+
// case 6:
96+
// text = 'weekend'
97+
// break;
98+
// default:
99+
// text = 'weekday'
100+
// }
101+
// console.log(text)

LearnJS2/students.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"name": "Subham",
4+
"age":20,
5+
"height": 170
6+
7+
},
8+
9+
10+
{
11+
"name":"Shekhar",
12+
"age":19,
13+
"height":168
14+
15+
}
16+
17+
]

0 commit comments

Comments
 (0)