Skip to content

Instantly share code, notes, and snippets.

@BernieGoll
Created June 14, 2018 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BernieGoll/7e3092c504e854231d84d8880ea9b8b0 to your computer and use it in GitHub Desktop.
Save BernieGoll/7e3092c504e854231d84d8880ea9b8b0 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/nevofag
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
//NEW PROBLEM, NEW BIN, BASICS, SIMPLE ARRAY -------
/*
let yourArray = ['three', 2, true, undefined, null,'harry' ];
console.log(yourArray.length); //output: 6
*/
//NEW PROBLEM -----------------
//Access Array using Bracket Notation & Changing Array
/*
let myArray = ["a", "b", "c", "d"];
console.log(myArray[1]);
// setting the 'b' to something else
myArray[1]= 'ding dong';
console.log(myArray);
*/
//NEW PROBLEM ------------------
// Add items to array with push() and unshift()
/*
let myArray = ["a", "b", "c", "d"];
myArray.unshift('d', 'c');
console.log(myArray);
let myArray = ["a", "b", "c", "d"];
myArray.push('a', 'b');
console.log(myArray);
*/
//NEW PROBLEM ---------------
// Remove items in array with pop and shift - NO PARAMETERS though
/*
let myArray = ["a", "b", "c", "d"];
myArray.pop();
console.log(myArray);
*/
/*
let myArray = ["a", "b", "c", "d"];
myArray.shift();
console.log(myArray);
*/
//NEW PROBLEM -----------------
// Using SLICE - extracts at a start, ending and makes new array w/ it
/*
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];
let todaysWeather = weatherConditions.slice(1, 3);
console.log(todaysWeather);
*/
//NEW PROBLEM ---------------------
// Using SPLICE - Removes any # of consecutive elements from array
//first parameter represents the index on the array from which to begin removing elements,
//while the second parameter indicates the number of elements to delete
/*
let array = ['today', 'was', 'not', 'so', 'great'];
array.splice(2, 2);
console.log(array);
*/
</script>
<script id="jsbin-source-javascript" type="text/javascript">//NEW PROBLEM, NEW BIN, BASICS, SIMPLE ARRAY -------
/*
let yourArray = ['three', 2, true, undefined, null,'harry' ];
console.log(yourArray.length); //output: 6
*/
//NEW PROBLEM -----------------
//Access Array using Bracket Notation & Changing Array
/*
let myArray = ["a", "b", "c", "d"];
console.log(myArray[1]);
// setting the 'b' to something else
myArray[1]= 'ding dong';
console.log(myArray);
*/
//NEW PROBLEM ------------------
// Add items to array with push() and unshift()
/*
let myArray = ["a", "b", "c", "d"];
myArray.unshift('d', 'c');
console.log(myArray);
let myArray = ["a", "b", "c", "d"];
myArray.push('a', 'b');
console.log(myArray);
*/
//NEW PROBLEM ---------------
// Remove items in array with pop and shift - NO PARAMETERS though
/*
let myArray = ["a", "b", "c", "d"];
myArray.pop();
console.log(myArray);
*/
/*
let myArray = ["a", "b", "c", "d"];
myArray.shift();
console.log(myArray);
*/
//NEW PROBLEM -----------------
// Using SLICE - extracts at a start, ending and makes new array w/ it
/*
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];
let todaysWeather = weatherConditions.slice(1, 3);
console.log(todaysWeather);
*/
//NEW PROBLEM ---------------------
// Using SPLICE - Removes any # of consecutive elements from array
//first parameter represents the index on the array from which to begin removing elements,
//while the second parameter indicates the number of elements to delete
/*
let array = ['today', 'was', 'not', 'so', 'great'];
array.splice(2, 2);
console.log(array);
*/
</script></body>
</html>
//NEW PROBLEM, NEW BIN, BASICS, SIMPLE ARRAY -------
/*
let yourArray = ['three', 2, true, undefined, null,'harry' ];
console.log(yourArray.length); //output: 6
*/
//NEW PROBLEM -----------------
//Access Array using Bracket Notation & Changing Array
/*
let myArray = ["a", "b", "c", "d"];
console.log(myArray[1]);
// setting the 'b' to something else
myArray[1]= 'ding dong';
console.log(myArray);
*/
//NEW PROBLEM ------------------
// Add items to array with push() and unshift()
/*
let myArray = ["a", "b", "c", "d"];
myArray.unshift('d', 'c');
console.log(myArray);
let myArray = ["a", "b", "c", "d"];
myArray.push('a', 'b');
console.log(myArray);
*/
//NEW PROBLEM ---------------
// Remove items in array with pop and shift - NO PARAMETERS though
/*
let myArray = ["a", "b", "c", "d"];
myArray.pop();
console.log(myArray);
*/
/*
let myArray = ["a", "b", "c", "d"];
myArray.shift();
console.log(myArray);
*/
//NEW PROBLEM -----------------
// Using SLICE - extracts at a start, ending and makes new array w/ it
/*
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];
let todaysWeather = weatherConditions.slice(1, 3);
console.log(todaysWeather);
*/
//NEW PROBLEM ---------------------
// Using SPLICE - Removes any # of consecutive elements from array
//first parameter represents the index on the array from which to begin removing elements,
//while the second parameter indicates the number of elements to delete
/*
let array = ['today', 'was', 'not', 'so', 'great'];
array.splice(2, 2);
console.log(array);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment