console.log("I am ok"); We can make pop-up boxes appear!
confirm("I am ok");prompt("Are you ok?");
2. Data types
a. numbers (e.g.
4.3, 134)b. strings (e.g.
"dogs go woof!", "JavaScript expert")c. booleans (e.g.
false, 5 > 4) 3. Conditionals
If the first condition is met, execute the first code block. If it is not met, execute the code in the
else block. See the code on the right for another exampleData types
a. numbers - just use them like regular numbers
b. strings - anything between a " " is a string. Words have to be strings.
c. booleans - can only be
true or false.Variables
We store data values in variables. We can bring back the values of these variables by typing the variable name.
Manipulating numbers & strings
a. numbers - comparison operators, modulo
b. strings - length, substring
console.log( )
Prints into the console whatever we put in the parentheses.
---->Functions
var nameString = function (name) {return console.log( "Hi. I am"+" " + name);
};
nameString("eli");
// alt ex
var orangeCost = function(price){
console.log(price *5);
};
orangeCost(5);
// Parameter is a number, and we do math with that parameter
// alt ex
var timesTwo = function(number) {
return number * 2;
};
// Call timesTwo here!
timesTwo(5);
No comments:
Post a Comment