%%html
<div>
<h1>Important Repositories</h1>
<p>These are repositories that I commonly use</p>
<button style="color:white;border-radius:20px;background-color:gray;border:2px solid black">Click to Switch the Links</button>
</div>
<div>
<a href="https://nighthawkcoders.github.io/teacher/">Nighthawk Teacher Repository</a><br />
<a href="https://dino596.github.io/csp/">Individual Student Repository</a>
<p>Bottom Text</p>
</div>
Important Repositories
These are repositories that I commonly use
%%js
var obj = {
name: "Arthur Liu",
age: 16,
height: 62.99,
classes: [
"Ethnic Literature I",
"AP United States History",
"AP Computer Science Principles",
"AP Chemistry"
],
groupMembers: [
"Jason",
"Isabelle",
"Matthew",
"Rayane"
],
sport: "Tennis",
instrument: "Piano"
}
console.log(obj)
obj.classes.push("AP Calculus BC")
console.log(obj)
console.log(obj.classes)
console.log(obj.name.indexOf(" "))
console.log(obj.name.substring(0,obj.name.indexOf(" ")))
var nameLen = obj.name.substring(0,obj.name.indexOf(" ")).length
for (let i = 0; i < obj.groupMembers.length; i++) {
nameLen += obj.groupMembers[i].length
}
console.log(nameLen / (obj.groupMembers.length + 1))
console.log(typeof obj.name)
console.log(typeof obj.height)
console.log(typeof obj.groupMembers)
<IPython.core.display.Javascript object>
%%html
<div style="background-color:lightgray;font-family:'lucida handwriting',cursive">
<h1 style="color:indigo">Important Repositories</h1>
<p id="pID" style="color:midnightblue">These are repositories that I commonly use</p>
<button onClick="switchLinks()" onmousedown="this.style.backgroundColor='lawngreen'" onmouseup="this.style.backgroundColor='lightcoral'"; style="color:white;border-radius:20px;background-color:lightcoral;border:2px solid black" id="buttonID">Click to Switch the Links</button>
</div>
<div id="links" style="background-color:honeydew;font-family:'brush script',cursive">
<a id="public" href="https://nighthawkcoders.github.io/teacher/">Nighthawk Teacher Repository<br /></a>
<a id="personal" href="https://dino596.github.io/csp/">Individual Student Repository<br /></a>
</div>
<script>
var first = "public"
function switchLinks() {
var pID = document.getElementById("pID")
pID.innerHTML = "Switched!"
var links = document.getElementById("links")
var public = document.getElementById("public")
var personal = document.getElementById("personal")
if (first == "public") {
links.insertBefore(personal,public)
first = "personal"
} else {
links.insertBefore(public,personal)
first = "public"
}
}
</script>
Important Repositories
These are repositories that I commonly use
%%html
<script>
var a = 3
var b = 2
if (a > b) {
console.log("A is greater than B")
} else if (a < b) {
console.log("B is greater than A")
} else if (a == b) {
console.log("A is equal to B")
}
</script>
%%js
var alphabet = "abcdefghijklmnopqrstuvwxyz";
var alphabetList = [];
for (var i = 0; i < alphabet.length; i++) {
alphabetList.push(alphabet[i]);
}
console.log(alphabetList);
<IPython.core.display.Javascript object>
%%js
var alphabet = "abcdefghijklmnopqrstuvwxyz";
var alphabetList = [];
for (var i = 0; i < alphabet.length; i++) {
alphabetList.push(alphabet[i]);
}
console.log(alphabetList);
var letterNumber = 5
for (var i = 0; i < alphabetList.length; i++) {
if (i == letterNumber) {
console.log(alphabet[letterNumber-1] + " is letter number " + letterNumber + " in the alphabet")
}
}
// Should output:
// "e" is letter number 5 in the alphabet
<IPython.core.display.Javascript object>
%%js
let odds = [];
let i = 1;
while (i <= 10) {
odds.push(i);
i += 2;
}
console.log(odds);
<IPython.core.display.Javascript object>
%%js
var numbers = []
var newNumbers = []
var i = 0
while (i <= 100) {
numbers.push(i)
i += 1
}
for (var i of numbers) {
if (numbers[i] % 5 == 0)
newNumbers.push(numbers[i])
else if (numbers[i] % 2 == 0)
newNumbers.push(numbers[i])
}
console.log(newNumbers)
<IPython.core.display.Javascript object>
%%js
var menu = {"burger": 3.99,
"fries": 1.99,
"drink": 0.99}
var total = 0
//shows the user the menu and prompts them to select an item
console.log("Menu")
for (var item in menu) {
console.log(item + " $" + menu[item].toFixed(2)) //why is toFixed used?
}
//ideally the code should support mutliple items
var item = "burger"
while (item != "q") {
item = prompt("What item do you want, \"q\" to quit")
if (["burger","fries","drink"].includes(item)) {
total += menu[item]
}
}
//code should add the price of the menu items selected by the user
console.log("$" + total.toFixed(2))
<IPython.core.display.Javascript object>