Ask a Question
Ask a Question
Ask a Question
Final Response
Final Response
Final Response
Final Response
var answer = "Hello";
alert(answer);
alert("answer");
if(answer == "hello"){
alert("This was the answer");
}
if(answer == "Hello"){
alert("No, I think this was the answer");
}
if(answer == Hello){
alert("Actually this might be correct");
}
var response = prompt("What's your name?");
alert("response");
Javascript is great at math
We can assign numbers to variables, but we don't use quotes, that way they know to treat it as a number and not a character.
var number = 1; // correct!
var number = "1"; // not a number!
What will this equal?
alert(9 + 4);
alert(9 - 4);
alert(9 * 4);
alert(9/4);
Make 4 different alerts
Each should output the number 36
The first one should use addition
then subtraction
then multiplication
then division.
Prove what you know!
var num1 = 6;
var num2 = 10;
var num3 = 4;
var num4 = 12;
alert(num1 - num3);
alert(num4 / num1);
alert(num3 * num3);
alert(num1 + num2 - num4);
In math, what does average mean?
How is average calculated?
var average1 = 5 + 4 + 6 / 3;
var average2 = (5 + 4 + 6) / 3;
alert(average1);
alert(average2);
What will each of these equal?
Which is actually the average?
var last_grade = prompt("what was your participation grade for last week?"); //30
var this_grade = prompt("What was your participation grade this week?"); //40
alert(last_grade + this_grade);
What will this alert?
Why?
var last_grade = prompt("what was your participation grade for last week?"); //30
var this_grade = prompt("What was your participation grade this week?"); //40
last_grade = parseInt(last_grade);
this_grade = parseInt(this_grade);
alert(last_grade + this_grade);
ParseInt turns strings into numbers.
Make your own program that has 4 prompts asking what grade you got in each quarter.
Then the program should tell the person what there final grade for the year will be.
Now change it so if you made an 85 or higher, it should say "Great job!"
If you made below an 85 it should say "Work harder next time!"
String Concatenation
var name = prompt("What's your name?");
alert("Hello " + name);
Now make it so your program says "Great job, you made a ___" if they have at or above an 85 and "Work harder next time, you made an ______" if they are below an 85.
1. Make a program that Alerts "Hello" in the browser.
2. Make the program ask "What grade are you in?"
3. Make the program say back to the person you have ____ years left until High School
4. Make the program say You must be in elementary school if the # of years to high school is greater than 4, if it's less than 4 it should say you're in middle school.
2. Make the program ask "How old are you?"
Make a program that asks the user 5 different math questions.
If the user answers correctly, tell them good job. If they miss it, tell them they were wrong.
After the 5 questions, the program should tell them their grade.