Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Class4/fun.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60 lines (43 sloc)
1.46 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = "hi"; //string - just holds text characters | |
var number = 3; // sumber | |
var bool = true; // boolean | |
var object = {"firstname":"joe","lastname":"smith", "enrolled":true,"age":25}; //this is sometimes reffered to as jasom - key value pairs all seperated by commas | |
//think of this as a way to hold or store data | |
var array = [2,3,4,5,6]; | |
//arrays do not have key value pairs, they hold values, could be any kind of data like a boolian or whatever | |
data = 10 - number; //not a good practice to do this - to change the data twice | |
//the name does not matter bc the type is based on the data you assign to it | |
//operators - = assigns values | |
data = 10 - number; //10-3 | |
data++; //10+1 | |
data--; //10-1 | |
var hello = "Hello"; | |
hello = hello + "there"; | |
hello = hello + 6; | |
console.log(hello); | |
console.log(data); | |
if(number >= 2) { | |
console.log("it is true");} | |
else if(number <=1) | |
{console.log("Something else is true")} | |
else{ | |
console.log("Everything else is false") | |
} | |
switch(data){ | |
case 1: | |
console.log("number is 1"); | |
break; | |
case 2: | |
console.log("number is 2"); | |
break; | |
default: | |
console.log("number is a number"); | |
break; | |
} | |
//each case is saying "if data =#, then run that case" | |
function logData(text) { //calling a function with a parameter | |
console.log(text) | |
} | |
logData(); | |
//the parenthases take in data and the curly brackets are what is contained in the function | |
//parameters are only used within the function |