Skip to content

Instantly share code, notes, and snippets.

@fnakstad
Created January 9, 2016 02:57
Show Gist options
  • Save fnakstad/2319f96b3d720071db51 to your computer and use it in GitHub Desktop.
Save fnakstad/2319f96b3d720071db51 to your computer and use it in GitHub Desktop.
console.log('*** VARIABLES ***');
// Declaration (make a new variable, and give it a name)
var person;
// Assignment (put a value inside the variable)
person = "Tomomi";
console.log(person);
person = "Frederik";
console.log(person);
var number = 1;
number = 245;
console.log(number);
number++;
console.log(number);
number = number + 10;
console.log(number);
console.log('*** FOR LOOPS ***')
var numOfLoops = 5;
for(var i = 0; i <= numOfLoops; i++) {
console.log(i);
console.log('Tomomi is cute!');
console.log('Frederik too');
}
console.log('=======');
console.log('Loop ended');
// Arrays
console.log('*** ARRAYS ***');
var manyNumbers = [1, 2, 3, 4, 5];
console.log(manyNumbers);
console.log(manyNumbers.length);
manyNumbers[0] = 300;
console.log(manyNumbers);
console.log(manyNumbers[0])
console.log(manyNumbers[4])
console.log(manyNumbers[5])
manyNumbers[2] = manyNumbers[3] + manyNumbers[0];
console.log(manyNumbers[2]);
console.log('PUSH!');
manyNumbers.push(999999);
console.log(manyNumbers);
console.log('\n*** Arrays in for loops ***')
manyNumbers.push(4);
manyNumbers.push(48);
for(var i = 0; i < manyNumbers.length; i++) {
console.log(i);
console.log(manyNumbers[i]);
console.log('---');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment