-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e6cc16
commit 24d5194
Showing
68 changed files
with
849 additions
and
849 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
|
||
<h2>Creating Object from JSON String</h2> | ||
|
||
<p id="JSONdemo"></p> | ||
|
||
<script> | ||
//JSON stands for JavaScript Object Notation. A JSON file has .json as its extension and the data inside are represented in a key:value pair | ||
|
||
let JSONdemo = '{"students":['+ | ||
'{"firstName":"Farheen","lastName":"Kazi" },' + | ||
'{"firstName":"Hira","lastName":"Amir" },' + | ||
'{"firstName":"Amber","lastName":"Arain" }]}'; | ||
|
||
//In JavaScript, JSON.parse() converts JSON data to objects and JSON.stringify() converts an object's key:value pair to JSON data. | ||
|
||
const obj = JSON.parse(JSONdemo); | ||
document.getElementById("JSONdemo").innerHTML = | ||
obj.students[1].firstName + " " + obj.students[1].lastName; | ||
</script> | ||
|
||
</body> | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
|
||
<h2>Creating Object from JSON String</h2> | ||
|
||
<p id="JSONdemo"></p> | ||
|
||
<script> | ||
//JSON stands for JavaScript Object Notation. A JSON file has .json as its extension and the data inside are represented in a key:value pair | ||
|
||
let JSONdemo = '{"students":['+ | ||
'{"firstName":"Farheen","lastName":"Kazi" },' + | ||
'{"firstName":"Hira","lastName":"Amir" },' + | ||
'{"firstName":"Amber","lastName":"Arain" }]}'; | ||
|
||
//In JavaScript, JSON.parse() converts JSON data to objects and JSON.stringify() converts an object's key:value pair to JSON data. | ||
|
||
const obj = JSON.parse(JSONdemo); | ||
document.getElementById("JSONdemo").innerHTML = | ||
obj.students[1].firstName + " " + obj.students[1].lastName; | ||
</script> | ||
|
||
</body> | ||
</html> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
|
||
.container { | ||
margin-top: 0px; | ||
text-align: center; | ||
} | ||
h1{ | ||
text-align: center; | ||
font-size: 28px; | ||
} | ||
input { | ||
width: 230px; | ||
height: 40px; | ||
border:5px solid #244624; | ||
border-radius: 21px; | ||
font-size: 34px; | ||
} | ||
button{ | ||
margin: 5px; | ||
border-radius: 20px; | ||
font-size: 30px; | ||
background: #978fa0; | ||
text-align: center; | ||
width: 50px; | ||
height: 50px; | ||
} | ||
.calculator { | ||
border: 4px solid #13695d; | ||
background-color: #ff99f7; | ||
padding: 8px; | ||
border-radius: 53px; | ||
display: inline-block; | ||
} | ||
span { | ||
color: rgb(26, 197, 209); | ||
font-size: larger; | ||
} | ||
|
||
|
||
.container { | ||
margin-top: 0px; | ||
text-align: center; | ||
} | ||
h1{ | ||
text-align: center; | ||
font-size: 28px; | ||
} | ||
input { | ||
width: 230px; | ||
height: 40px; | ||
border:5px solid #244624; | ||
border-radius: 21px; | ||
font-size: 34px; | ||
} | ||
button{ | ||
margin: 5px; | ||
border-radius: 20px; | ||
font-size: 30px; | ||
background: #978fa0; | ||
text-align: center; | ||
width: 50px; | ||
height: 50px; | ||
} | ||
.calculator { | ||
border: 4px solid #13695d; | ||
background-color: #ff99f7; | ||
padding: 8px; | ||
border-radius: 53px; | ||
display: inline-block; | ||
} | ||
span { | ||
color: rgb(26, 197, 209); | ||
font-size: larger; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="Calculator.css"> | ||
<title>Caculator</title> | ||
|
||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Caculator by <span>Dilpat Rai</span></h1> | ||
<div class="calculator"> | ||
<input type="text"name="screen" id="screen"> | ||
<table> | ||
<tr> | ||
<td><button>(</button></td> | ||
<td><button>)</button></td> | ||
<td><button>C</button></td> | ||
<td><button>%</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>7</button></td> | ||
<td><button>8</button></td> | ||
<td><button>9</button></td> | ||
<td><button>X</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>4</button></td> | ||
<td><button>5</button></td> | ||
<td><button>6</button></td> | ||
<td><button>-</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>1</button></td> | ||
<td><button>2</button></td> | ||
<td><button>3</button></td> | ||
<td><button>+</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>0</button></td> | ||
<td><button>.</button></td> | ||
<td><button>/</button></td> | ||
<td><button>=</button></td> | ||
|
||
</tr> | ||
|
||
</table> | ||
</div> | ||
</div> | ||
<script src="Calculator.js"></script> | ||
|
||
</body> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="Calculator.css"> | ||
<title>Caculator</title> | ||
|
||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Caculator by <span>Dilpat Rai</span></h1> | ||
<div class="calculator"> | ||
<input type="text"name="screen" id="screen"> | ||
<table> | ||
<tr> | ||
<td><button>(</button></td> | ||
<td><button>)</button></td> | ||
<td><button>C</button></td> | ||
<td><button>%</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>7</button></td> | ||
<td><button>8</button></td> | ||
<td><button>9</button></td> | ||
<td><button>X</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>4</button></td> | ||
<td><button>5</button></td> | ||
<td><button>6</button></td> | ||
<td><button>-</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>1</button></td> | ||
<td><button>2</button></td> | ||
<td><button>3</button></td> | ||
<td><button>+</button></td> | ||
|
||
</tr> | ||
<tr> | ||
<td><button>0</button></td> | ||
<td><button>.</button></td> | ||
<td><button>/</button></td> | ||
<td><button>=</button></td> | ||
|
||
</tr> | ||
|
||
</table> | ||
</div> | ||
</div> | ||
<script src="Calculator.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
let screen = document.getElementById('screen'); | ||
buttons = document.querySelectorAll('button'); | ||
let screenValue = ""; | ||
for(item of buttons){ | ||
item.addEventListener('click', (e) => { | ||
buttonText = e.target.innerText; | ||
console.log(buttonText); | ||
if(buttonText == 'X') { | ||
buttonText = '*'; | ||
screenValue+=buttonText; | ||
screen.value = screenValue; | ||
} | ||
else if(buttonText == 'C'){ | ||
screenValue = ""; | ||
screen.value = screenValue; | ||
} | ||
else if(buttonText == '='){ | ||
screen.value = eval(screenValue); | ||
screenValue = ""; | ||
} | ||
else { | ||
screenValue+= buttonText; | ||
screen.value = screenValue; | ||
} | ||
}) | ||
let screen = document.getElementById('screen'); | ||
buttons = document.querySelectorAll('button'); | ||
let screenValue = ""; | ||
for(item of buttons){ | ||
item.addEventListener('click', (e) => { | ||
buttonText = e.target.innerText; | ||
console.log(buttonText); | ||
if(buttonText == 'X') { | ||
buttonText = '*'; | ||
screenValue+=buttonText; | ||
screen.value = screenValue; | ||
} | ||
else if(buttonText == 'C'){ | ||
screenValue = ""; | ||
screen.value = screenValue; | ||
} | ||
else if(buttonText == '='){ | ||
screen.value = eval(screenValue); | ||
screenValue = ""; | ||
} | ||
else { | ||
screenValue+= buttonText; | ||
screen.value = screenValue; | ||
} | ||
}) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
Oops, something went wrong.