You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//console.log("Hello, World!");//console.log("I like pizza");//window.alert("This is an aleart")//window.alert("I like pizza!");document.getElementById("myH1").textContent="Hello";document.getElementById("myP").textContent="I like pizza";//This is a comment
/* variable = A container that stores a value Behaves as if it were the value it contains1. declaration let x;2. assigment x = 100;You can only declare a variable one time, you can't declare more than one variable of same name*/letage=25;console.log(`you are ${age} years old`)// This console command will show "you are 25 years old" on the console -> IT NEEDS TO START AND END WITH "`"//letprice=10.99console.log(`The price is $${price}`);letfavFood=prompt("What is your favorite food?");console.log(`You favorite food is ${favFood}!`)
letonline=trueconsole.log(typeofonline)//This a *boolean*, is used to verify something//
letfullName="Pedro Victor Martins Câmara";letage=21;letstudent=true;document.getElementById("p1").textContent=`Your namew is ${fullName}`;document.getElementById("p2").textContent=`You are ${age} years old`;document.getElementById("p3").textContent=`Enrolled: ${student}`;
Arithmetic operators
/*arithmetic operators= operands (values, variables, etc.) operators (+ - * /) ex. 11 = x + 5;*/letstudents=30;//students = students + 1;//students = students - 1;//students = students * 2; -> multiplication//students = students / 2; -> division//students = students ** 2; -> the (variable) is multiply by itself the amount of times that is define by the number after the "**"//let extraStudents = students % 2; -> the module, the rest of the division//students += 1; -> students = 31//students -= 1; -> students = 29//students *= 2; -> students = 60//students /= 2; -> students = 15//students **= 2; -> students = 900//students %= 2; -> students = 0//students++; -> students = 31//students--; -> students = 29
Operator precedence
/* operator precedence 1. parenthesis () 2. exponents 3. multiplication & division & modulo 4. addition & subtraction*/letresult=1+2*3+4**2;// the result is 23
How to accept user input
1. EASY WAY = window prompt
letusername;username=window.prompt("What's your username?")console.log(username)document.getElementById("p1").textContent=username
//const = a variable that can't be changedconstpi=3.14159;letradius;letcircumference;radius=window.prompt('Enter the radius of a circle')radius=Number(radius);circumference=2*pi*radius;console.log(circumference)