August 2023 to June 2024
View the Project on GitHub IshanCornick/new_student
Home | HTML | JavaScript | DOM | Data Types | JS Debugging |
<script></script>
in your markdown or jupyter cells%%html
<h3>Page Heading</h3>
<p>Paragraph description of page</p>
<script>
console.log("Output to console, showing that JavaScript code is running")
</script>
Paragraph description of page
console.log
appears in the Consoleconsole.log
allows you to write text – but you don’t see any text in above example until you view Console.variable
with a name and a value.var someName = value;
console.log
%%html
<script>
// create variables
var firstName = "Rohan"
var lastName = 'Juneja'
var age = 17;
var isSchoolDay = true;
// inspect values and type
console.log(firstName, typeof firstName)
console.log(lastName, typeof lastName)
console.log(age, typeof age)
console.log(isSchoolDay, typeof isSchoolDay)
</script>
true
, otherwise false
%%html
<script>
// string assignment
var name1 = "Doe"
var name2 = "Doe"
// compare names
console.log("String Comparison")
console.log("name1", name1)
console.log("name2", name2)
console.log("name1 == name2", name1 == name2)
// changing the value of name1 and repeat compare
console.log("String Comparison after change")
name1 = "John" // reassign
console.log("name1", name1)
console.log("name2", name2)
console.log("name1 == name2", name1 == name2)
console.log("String Concatenation")
console.log(name1 + " " + name2)
</script>
true
, otherwise false
%%html
<script>
var age1 = 17
var age2 = 16
var age3 = '17'
console.log("Number Comparisons")
console.log("age1:", age1)
console.log("age2:", age2)
console.log("age3:", age3)
console.log("age1 == age2", age1 == age2)
console.log("age1 == age3", age1 == age3)
console.log("age1 === age3", age1 === age3)
console.log("age1 > age2", age1 > age2)
console.log("age1 < age2", age1 < age2)
var num1 = 9
var num2 = 5
console.log("\n")
console.log("Arithmetic Operations")
console.log("num1:", num1)
console.log("num2:", num2)
console.log("num1 + num2", num1 + num2)
console.log("num1 - num2", num1 - num2)
console.log("num1 * num2", num1 * num2)
console.log("num1 / num2", num1 / num2)
console.log("num1 % num2", num1 % num2)
</script>
%%html
<script>
// the above example in code
console.log("Alarm Example")
var tommorowIsSchoolDay = false
if (tommorowIsSchoolDay) {
// this code runs if tommorw is a school day
console.log("Setting alarm for 8am")
} else {
// this code runs if tommorow is not a school day
console.log("Setting alarm for 10am")
}
</script>
%%html
<script>
console.log("If statements + Operators")
var age1 = 17
var age2 = 37
if (age1 > age2) {
// runs if age1 is more than age2
console.log("age1 is more than age2")
} else if (age1 == age2) {
// runs if age1 and age2 are the same
console.log("age1 is the same as age2")
// (age1 < age2)
} else {
// runs if age2 is more than age1
console.log("age1 is less than age2")
}
</script>
%%js
// put your javascript code here
// Welcome to the Enchanted Forest Quest!
// Our brave adventurer, with the code name 'a', sets forth on a quest!
const a = 10;
// The mystical guardian 'b' guards the entrance to a hidden treasure chamber!
const b = 20;
// The adventurer faces a crucial decision: to challenge or retreat!
if (a > b) {
console.log("The fearless frog 'a' bravley crosses the roads with cars");
} else if (b > a) {
console.log("The river with 'b' prevails, making sure that no one can cross");
} else {
console.log("The frog 'a' and the river 'b' begin fighting");
}
<IPython.core.display.Javascript object>
Home | HTML | JavaScript | DOM | Data Types | JS Debugging |
<script></script>
in your markdown or jupyter cells%%html
<h3>Page Heading</h3>
<p>Paragraph description of page</p>
<script>
console.log("Output to console, showing that JavaScript code is running")
</script>
Paragraph description of page
console.log
appears in the Consoleconsole.log
allows you to write text – but you don’t see any text in above example until you view Console.variable
with a name and a value.var someName = value;
console.log
%%html
<script>
// create variables
var firstName = "Rohan"
var lastName = 'Juneja'
var age = 17;
var isSchoolDay = true;
// inspect values and type
console.log(firstName, typeof firstName)
console.log(lastName, typeof lastName)
console.log(age, typeof age)
console.log(isSchoolDay, typeof isSchoolDay)
</script>
true
, otherwise false
%%html
<script>
// string assignment
var name1 = "Doe"
var name2 = "Doe"
// compare names
console.log("String Comparison")
console.log("name1", name1)
console.log("name2", name2)
console.log("name1 == name2", name1 == name2)
// changing the value of name1 and repeat compare
console.log("String Comparison after change")
name1 = "John" // reassign
console.log("name1", name1)
console.log("name2", name2)
console.log("name1 == name2", name1 == name2)
console.log("String Concatenation")
console.log(name1 + " " + name2)
</script>
true
, otherwise false
%%html
<script>
var age1 = 17
var age2 = 16
var age3 = '17'
console.log("Number Comparisons")
console.log("age1:", age1)
console.log("age2:", age2)
console.log("age3:", age3)
console.log("age1 == age2", age1 == age2)
console.log("age1 == age3", age1 == age3)
console.log("age1 === age3", age1 === age3)
console.log("age1 > age2", age1 > age2)
console.log("age1 < age2", age1 < age2)
var num1 = 9
var num2 = 5
console.log("\n")
console.log("Arithmetic Operations")
console.log("num1:", num1)
console.log("num2:", num2)
console.log("num1 + num2", num1 + num2)
console.log("num1 - num2", num1 - num2)
console.log("num1 * num2", num1 * num2)
console.log("num1 / num2", num1 / num2)
console.log("num1 % num2", num1 % num2)
</script>
%%html
<script>
// the above example in code
console.log("Alarm Example")
var tommorowIsSchoolDay = false
if (tommorowIsSchoolDay) {
// this code runs if tommorw is a school day
console.log("Setting alarm for 8am")
} else {
// this code runs if tommorow is not a school day
console.log("Setting alarm for 10am")
}
</script>
%%html
<script>
console.log("If statements + Operators")
var age1 = 17
var age2 = 37
if (age1 > age2) {
// runs if age1 is more than age2
console.log("age1 is more than age2")
} else if (age1 == age2) {
// runs if age1 and age2 are the same
console.log("age1 is the same as age2")
// (age1 < age2)
} else {
// runs if age2 is more than age1
console.log("age1 is less than age2")
}
</script>
%%js
// put your javascript code here
// Welcome to the Enchanted Forest Quest!
// Our brave adventurer, with the code name 'a', sets forth on a quest!
const a = 10;
// The mystical guardian 'b' guards the entrance to a hidden treasure chamber!
const b = 20;
// The adventurer faces a crucial decision: to challenge or retreat!
if (a > b) {
console.log("The fearless frog 'a' bravley crosses the roads with cars");
} else if (b > a) {
console.log("The river with 'b' prevails, making sure that no one can cross");
} else {
console.log("The frog 'a' and the river 'b' begin fighting");
}
<IPython.core.display.Javascript object>