home..

Basics of Javascript

Home HTML JavaScript DOM Data Types Correcting errors

How to use javascript in any of your pages

%%html

Page Heading

Paragraph description of page

Writing text to console.log

Try code with Console

Storing data

Types of data

Name the Data

Accessing data

%%html

String Operators

Assignment Operator

%%html

Number Operators

Assignment Operator

%%html

Conditional Statements

%%html

Conditional Statements + Operators

%%html

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>

Hacks

%%js
//generates random values for a and b
var a = Math.floor(Math.random() * 100);
var b = Math.floor(Math.random() * 100);

console.log("The value of A is: " + a);
console.log("The value of B is: " + b);

//checks if a is greater than b
if (a > b) {
    console.log("a is greater than b");
}
//checks if a and b are equal
else if(a == b) {
    console.log("a and b are equal");
}
else {
    console.log("a is less than b");
}
<IPython.core.display.Javascript object>
© 2024    •  Powered by Soopr   •  Theme  Moonwalk