Giter Site home page Giter Site logo

javascript-arrays's Introduction

JavaScript Arrays

Objectives

  • Explain what an array is and why we use it
  • Create an array
  • Add an element to an array
  • Access an element in an array
  • Delete an element from an array

Instructions

You'll be coding along in arrays.js. There are tests to run to make sure you're on the right track.

Introduction

Let's say that we have a list of ingredients for a kickin' grilled cheese (code along in console):

var ingredient1 = "bread"
var ingredient2 = "mild cheese"
var ingredient3 = "sharp cheese"
var ingredient4 = "butter"
var ingredient5 = "tomato"
var ingredient6 = "garlic"

But now what if we want to make a tomato sauce? Well, we already have garlic and tomato — but we have no idea what recipe they belong to. Pretty soon, we'll have a hard time keeping our ingredients safe, and we'd end up with bread in our tomato sauce.

noooooooo

This is an admittedly contrived example, but it goes to show that we can't just put everything in a variable and hope to remember what order things should go in. It also shows that sometimes it would be helpful to be able to group like items together.

In JavaScript, we can group like items in an object (well, everything in JavaScript is an object — but more on that some other time) called an array. An array is an ordered list of items (called "elements" of the array) separated by commas.

Arrays look like this: [1, 2, 3].

Or like this:

var grilledCheeseIngredients = [
  'bread',
  'mild cheese',
  'sharp cheese',
  'butter',
  'tomato',
  'garlic'
]

var tomatoSauceIngredients = [
  'tomato',
  'garlic',
  'olive oil',
  'basil',
  'oregano'
]

Creation

JavaScript arrays can contain all types of values and they can be of mixed types. You can create arrays in two different ways, the most common of which is to list values in a pair of square brackets. These are called array literals.

var myArray = [element0, element1, ..., elementN];

Examples:

var primeNumbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37];

var tvShows = ["game of thrones", "true detective", "the good wife", "empire"];

var weirdGreeting = [ "he", 110, "w", 0, "r", 1, "d" ];

var empty = [];

The Array constructor is another approach to making a new array.

var evenNumbers = new Array();

Arrays are ordered, meaning that the elements in them will always appear in the same order. The array [1, 1, 2], is different from the array [1, 2, 1].

TODO: In arrays.js, define a variable called chocolateBars. Its value should be an array of the strings snickers, hundred grand, kitkat, and skittles.

Adding an Element

JavaScript allows us to push elements onto the end of an array:

var superheroines = ["catwoman", "she-hulk", "mystique"];

superheroines.push("wonder woman");
// superheroines is now ["catwoman", "she-hulk", "mystique", "wonder woman"]

We can also unshift elements onto the beginning of an array:

var cities = ["New York", "San Francisco"]

cities.unshift("Philadelphia")

// cities is now ["Philadelphia", "New York", "San Francisco"]

These actions change the underlying array — in other words, they mutate its value.

Most modern browsers (Chrome, FireFox, and Safari) support what is called the spread operator — it's three dots in a row: .... When used with an array, it spreads out the array's contents.

We can use the spread operator to create a new array in place, rather than modifying the original one. Let's try it!

var cities = ["New York", "San Francisco"]

["Philadelphia", ...cities] // ["Philadelphia", "New York", "San Francisco"]

cities // ["New York", "San Francisco"]

Whoa! Did you see that? Our cities array was untouched when we used the spread operator: ...cities. We can do the same at the beginning of the array:

var cities = ["New York", "San Francisco"]

[...cities, "Philadelphia"] // ["New York", "San Francisco", "Philadelphia"]

To preserve the new array, we need to assign it to a variable:

var cities = ["New York", "San Francisco"]

// we can assign it to the existing `cities` variable
cities = ["Philadelphia", ...cities]

// but if we have a const
const cats = ["Milo", "Garfield"]

// we need a new variable:
const moreCats = ["Felix", ...cats]

While we can add elements to an array directly at specific indexes

var myArray = [1, 2, 3]

myArray[5] = 5

myArray // [1, 2, 3, undefined, undefined, 5]

it's best not to. We should treat arrays as ordered lists of information that can be any length, so updating a specific index should feel like a weird thing to do. Moreover, adding elements directly inserts undefined (as demonstrated above) if we also need to increase the array's length, which can lead to unexpected behavior.

TODO: In arrays.js, define two functions, addElementToBeginningOfArray and destructivelyAddElementToBeginningOfArray. Both functions take two parameters, an array and an element to add to the beginning of the array, and both functions should add the element to the beginning of the array and then return the whole array. The destructive function, destructivelyAddElementToBeginningOfArray, should alter the original array that's passed in; addElementToBeginningOfArray, on the other hand, should return a new array and not modify the original.

TODO: Define two more functions, addElementToEndOfArray and destructivelyAddElementToEndOfArray. These functions also take two arguments, an array and an element to add to the end of the array. addElementToEndOfArray should not alter the original array; destructivelyAddElementToEndOfArray should alter the original array.

Accessing an Element

You can get elements out of arrays if you know their index. Array elements' indexes start at 0 and increment by 1, so the first element's index is 0, the second element's index is 1, the third element's is 2, etc.

var entrepreneurs = ["Oprah Winfrey", "Laurene Powell Jobs", "Arianna Huffington"];

// the line below will print the string "Oprah Winfrey"
console.log(entrepreneurs[0]);

// the code below will print the string "Arianna Huffington is the co-founder and editress-in-chief of The Huffington Post"
var bio = " is the co-founder and editress-in-chief of The Huffington Post";
console.log(entrepreneurs[2] + bio);

// the line below will return undefined
entrepreneurs[9];

TODO: Define a function in arrays.js called accessElementInArray. The function should accept an array and an index and return the element at that index.

Removing an Element

From the Beginning of an Array

To remove an element from the beginning of an array, we can use the shift method:

const days = ["Monday", "Tuesday", "Wednesday"]

days.shift() // returns the removed element, in this case "Monday"

days // ["Tuesday", "Wednesday"]

As with unshift, this method is destructive; it mutates the underlying array.

TODO: Define a function in arrays.js called destructivelyRemoveElementFromBeginningOfArray that takes an array as its only argument and removes the first element. Your function should then return the entire array, and it should mutate the array.

Because we tend to want to avoid destruction, there is also a way to remove the first element from an array without changing the underlying array: we can use the slice method.

slice does just what its name implies: it takes a slice from its array. The first argument specifies where the slice starts, and the second argument specifies where it ends. If there is no second argument, the slice goes from the first argument (the start) to the end of the array. This means removing the first element is as simple as slice(1).

var cats = ["Milo", "Garfield", "Otis"]

cats.slice(1) // ["Garfield", "Otis"]

cats // ["Milo", "Garfield", "Otis"]

As with other non-destructive methods, we need to assign the results to a new variable to save our changes:

var cats = ["Milo", "Garfield", "Otis"]

cats = cats.slice(1) // ["Garfield", "Otis"]

cats // ["Garfield", "Otis"]

slice is also handy if we know we want the last n elements of an array: pass it a negative index.

var cats = ["Milo", "Garfield", "Otis"]

// get the last 2 cats
cats.slice(-2) // ["Garfield", "Otis"]

// get the last 1 cat
cats.slice(-1) // ["Otis"]

TODO: Define a function in arrays.js called removeElementFromBeginningOfArray. It takes an array as its only argument. The function should remove the first element in the array. This function should return the entire array in the same line, and it should not mutate the original array.

From the End of an Array

To remove an element from the end of an array, we can use the pop method:

var iceCreams = ["chocolate", "vanilla", "raspberry"]

iceCreams.pop() // returns the removed element, in this case "raspberry"

iceCreams // ["chocolate", "vanilla"]

As with push, this method is destructive; it mutates the underlying array.

TODO: Define a function in arrays.js called destructivelyRemoveElementFromEndOfArray that takes an array as its only argument and removes the last element. Your function should return the entire array, and it should mutate the array.

We can use slice to perform the above action without changing the underlying array. It takes a bit more work than removing the first element, since we want the slice from index 0 (remember, the first element is at index 0!) to the end. Hmmmm — what property do arrays have that can help us? length!

var iceCreams = ["chocolate", "vanilla", "raspberry"]

iceCreams.slice(0, iceCreams.length - 1) // ["chocolate", "vanilla"]

iceCreams // ["chocolate", "vanilla", "raspberry"]

TODO: Define a function in arrays.js called removeElementFromEndOfArray that takes an array as its only argument and removes the last element. Your function should return the array without the last element, and it should not mutate the original array.

From the Middle of an Array

Removing an element from the middle of an array in JavaScript is a bit trickier than removing an element from the beginning or end. We have the splice method, which takes an index in the array as its first argument, the number of elements to remove as its second argument, and any number of elements to add as any arguments after the second. All arguments are optional, but with no arguments, splice() returns an empty array and does nothing to the target array.

It might be helpful to refer to MDN to check out their examples, in addition to our examples here.

let items = [1, 2, 3, 4]

// this will remove everything after index 1 (inclusive)
// it returns the removed items: [2, 3, 4]
items.splice(1)

items // [1]

items = [1, 2, 3, 4]

 // "at index 1, remove 1 item"
 // it returns the removed item(s): [2]
items.splice(1, 1)

items // [1, 3, 4]

items = [1, 2, 3, 4]

// "at index 1, remove 1 item and add 6 and add 7"
// it returns the removed items: [2]
// and adds the items to add starting at the removal index
items.splice(1, 1, 6, 7)

items // [1, 6, 7, 3, 4]

As we noted above, adding elements at specific indexes in the middle of an array feels weird — it's intentionally difficult to do, as doing so with objects (where we have keys instead of sequential indexes) is much more natural.

BONUS

We can use slice, combined with the spread operator, to make removing from the middle of an array much easier.

var items = [1, 2, 3, 4, 5]

// let's remove the third element

// a slice from the start up to but not including index 2 (the third element)
// and a slice from index 3 to the end
[...items.slice(0, 2), ...items.slice(3)] // [1, 2, 4, 5]

Play around with this a bit until it makes sense. It's the trickiest thing that you've encountered so far, so don't sweat it if it takes a little bit to sink in!

Array Wackiness

Array indexes aren't exactly what they seem to be

If you had to guess, would you say that array indexes are numbers or strings? Think about it for a second, then read on.

Array indexes are actually strings, even though we commonly refer to them as numbers. But you don't have to take my word for it: try typing Object.keys([1, 2, ,3]) in your console and see what comes back.

Ultimately, this means array indexes are strings that can be accessed by array-style notation using brackets, and the numbers will be coerced into strings when they're needed under the hood. In a console, try accessing an index using a string to see for yourself:

var arr = ["under", "the", "hood"];

arr[0];  // "under"
arr['0']; // "under"
arr[02]; // 02 the number *is* 2, so you get "hood"
arr['02']: // '02' the string is *not* 2, so you get undefined

This little tidbit might come in handy if you ever try to assign a value to an array index by using a string unintentionally. Like, say, by getting your array positions from a zero-filled formatted list of numbers which you store as strings, then using those strings to access array elements.

Or by indexing an array with a variable whose contents don't in any way represent a number--like typing myArray['bonobo monkey'] = 27.

You'll get no complaints, because rather than adding an index to the array, you're adding a property. Speaking of which...

We can add properties to arrays

In JavaScript, everything is ultimately an object. We'll explore more about what that means when we cover objects, but for now, know that this means that we can add properties to just about anything, including arrays.

A property is a named piece of information. They're kind of like variables (don't go too far with that analogy) but we can only get that information with reference to the property owner.

What makes arrays special, then? Arrays keep track of how many elements they have in them via the length property: [1, 2, 3].length // 3. length doesn't work like other keys/indexes in objects/arrays — it updates automatically, and if we change it, we change the whole array.

var myArray = [1, 2, 3]

myArray.length // 3

myArray.length = 1

myArray // [1] (!!!)

It's important to remember that arrays in JavaScript are kind of wonky. You can assign properties to them:

var array = [1, 2, 3];

array.myProperty = "I'm a property!";

Which can lead to weird behavior:

array;
// [1, 2, 3];

// Where did our property go?
array.myProperty;
// "I'm a property!";

array.length;
// 3 - Would you have expected 3 or 4?

We don't tend to do these kinds of things on purpose, but it's important to be aware that they can happen so that you have a good sense of where to look if/when strange bugs start to appear.

Resources

javascript-arrays's People

Contributors

annjohn avatar aturkewi avatar chriswigington avatar dakotalmartinez avatar danielseehausen avatar danl12186 avatar dependabot[bot] avatar devinburnette avatar drakeltheryuujin avatar gj avatar hatetank avatar ihollander avatar ipc103 avatar ivalentine avatar jonbf avatar kthffmn avatar lizbur10 avatar maxwellbenton avatar mo6709 avatar pletcher avatar salinahum avatar samnags avatar sgharms avatar tvpeter avatar victhevenot avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-arrays's Issues

FROM THE BEGINNING OF AN ARRAY

var cats = ["Milo", "Garfield", "Otis"]

cats.slice(1) // ["Garfield", "Otis"]

cats // ["Milo", "Garfield", "Otis"]

Hello! I found an error. slice is referring to the 1st index but removes "Milo"

I just tried it in Atom and found out that it doesn't refer to the index of the array. But the actual position of "Milo" being in the first position. Since there was only one argument it started from the beginning to 1. I was unclear and had to do some testing. :P

"before all" hook error

In lab "javascript-arrays-lab-bootcamp-prep-000," I get the following error:

  1. "before all" hook:
    Error: Cannot find module 'jsdom/lib/old-api'
    at require (internal/module.js:11:18)
    at Context. (node_modules/mocha-jsdom/index.js:53:5)

See attached picture:
image

To fix, I have to install [email protected]:

[03:36:08] (master) javascript-arrays-lab-bootcamp-prep-000
// ♥ npm install [email protected]
npm notice created a lockfile as package-lock.json. You should commit this file.

  • [email protected]
    added 16 packages, removed 134 packages and updated 78 packages in 4.724s

Lab works as expected after update.

This is is not the first occurrence of this issue. It also happened in the lab immediately preceding this one. I am including a dump of my console output up to this point.
console_output.txt


Note: Package Manager reports some unresolved package version issues; packages are deprecated, superseded by more current version/application

npm WARN deprecated [email protected]: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: to-iso-string has been deprecated, use@segment/to-iso-string instead.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higherto avoid a RegExp DoS issue
npm WARN notice [SECURITY] growl has the following vulnerability: 1 critical. Go here for more details: https://nodesecurity.io/advisories?search=growl&version=1.9.2 - Run npm i npm@latest -g to upgrade your npm version, and then npm audit to get more info.
npm WARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=debug&version=0.7.4 - Run npm i npm@latest -g to upgrade your npm version, and then npm audit to get more info.
npm WARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=debug&version=2.2.0 - Run npm i npm@latest -g to upgrade your npm version, and then npm audit to get more info.
npm WARN notice [SECURITY] minimatch has the following vulnerability: 1 high. Go here for more details: https://nodesecurity.io/advisories?search=minimatch&version=0.3.0 - Run npm i npm@latest -g to upgrade your npm version, and then npm audit to get more info.
added 122 packages and updated 10 packages in 4.123s


todo vs solution vs tests

The TODO says to define a function called chocolateBars. However simply writing a function chocolateBars that returns the array doesn't work. The test wants you to write a variable chocolateBars that points to function returning array. As a side note, test also passes with a variable assigned to an array of chocolate bars, not a function

length function

var iceCreams = ["chocolate", "vanilla", "raspberry"]

iceCreams.slice(0, iceCreams.length - 1) // ["chocolate", "vanilla"]
Aren't
iceCreams.slice(0) = "chocolate" and
iceCreams.slice(iceCreams.length-1) = "raspberry" (not "vanilla!)?

iceCreams // ["chocolate", "vanilla", "raspberry"]

Suggestion

This is not a real issue-flag, but a passing suggestion: you might take Elizabeth Holmes out of your example array of female entrepreneurs. Just as today you probably wouldn't create an array like
var attorneys = ["Michael Cohen", "Gloria Allred"]
or
var entertainers = ["Bill Cosby", "Brad Pitt"]
it's a bit strange to see Elizabeth Holmes listed as an entrepreneur among the likes of Laurene Powell Jobs and Arianna Huffington at this point.

lab environment

Hello, I am having an issue opening the lab environment. When I left mouse click the big blue "open" button nothing happens.

there are no tests for destructivelyRemove

in the test code...

removeElementFromBeginningOfArray and removeElementFromEndOfArray are both testing for the 'destructive' versions of the code, instead of the 'does not alter array'.

issue being, if you follow the instructions implicitly, you will never pass because the test will always come back with errors.

ask a question tab

i was in the middle of discussing a question and i had to refresh my page do to internet and now my "ask a question" tab is not working

can't copy paste from the IDE terminal

using Windows I can Ctrl + c my code and Ctrl+ v it to the Flatiron help chat. However, anytime I try to do that in the IDE terminal it shows ^C in the type window and that's it.

Reference errors

I believe I have the correct js code, but I get the following error when I test it:

arrays addElementToBeginningOfArray(array, element) adds an element to the beginning of an array:
ReferenceError: addElementToBeginningOfArray is not defined

Lesson description not correct

Functions destructivelyRemoveElementFromBeginningOfArray and destructivelyRemoveElementFromEndOfArray are not defined in array-test.js.
TODO's for these functions ("should mutate array") should reflect correct functions and be renamed to removeElementFromBeginningOfArray and removeElementFromEndOfArray.

Remove TODO's ("should NOT mutate array") for functions removeElementFromBeginningOfArray and removeElementFromEndOfArray because these specific tests are not included in array-test.js.

Misleading removeElementFromBeginningOfArray instructions?

TODO: Define a function in arrays.js called removeElementFromBeginningOfArray that takes an array as its only argument and removes the first element. Your function should then return the entire array, and it should not mutate the underlying array.

It sounds like first, you remove the element with slice, and then, you return the entire array in another line. When the solution is:

function removeElementFromBeginningOfArray(array) {
  return array.slice(1)
}

I was stuck because of the wording.

Labs are passing with wrong code entries

  1. arrays "before all" hook:
    Error: timeout of 2000ms exceeded. Ensure the done() callback is being ca
    lled in this test.
    at Object.done (node_modules/mocha-jsdom/index.js:70:7)
    at process.nextTick (node_modules/jsdom/lib/jsdom.js:320:18)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

removeElementFromEndOfArray(array) test

removeElementFromEndOfArray(array) test allows you to pass using "array.splice(2)". Based on the text it looks like it should be forcing you to use "array = array.slice(0, array.length - 1)" instead.

spelling error

In the arrays-tests.js, destructively is spelled incorrectly fyi ---

describe('descructivelyAddElementToBeginningOfArray(array, element)', () => {
it('adds an element to the beginning of an array', () => {
expect(descructivelyAddElementToBeginningOfArray([1], 'foo')).to.eql(['foo', 1])
})

it('alters `array`', () => {
  const array = [1]

  **descructively**AddElementToBeginningOfArray(array, 'foo')

  expect(array).to.eql(['foo', 1])
})

})

Failing All Tests

Hello! I've been working on this lab piece by piece. I would run 'learn test' periodically and see that I was making progress, but now that I've written out all the code it says I'm failing all 16 tests? I don't totally understand how the learn test command works, but it seems like it's looking at the right file to read whether my code is there. I can tell something is wrong because it's failing the first test, ' 1) arrays chocolateBars is an array containing "snickers", "hundred grand", "kitkat", and "skittles":' and you can see in the screenshot that it's defined.

Please help, I want to keep learning but I don't want to leave this 'imcomplete'.
screen shot 2017-08-14 at 11 40 55 am

Typo

simply pass it an negative index.

Consistent Error Message

I'm receiving a consistent error for the Javascript Arrays lab. I've tried uninstalling and restarting my Learn app with no success. I've also tried deleting the arrays.js file and creating a new one. The error message is below:

This directory doesn't appear to have any specs in it.

Any help on resolving this issue would be greatly appreciated.

missing comma

in the lesson content, it's missing a comma between 3 and 4 under the section "FROM THE MIDDLE OF AN ARRAY"

---> items // [1, 6, 7, 3 4]

Tests not passing until page was refreshed

I'm not sure if this is for all the tests, but for at least the first test--"define array named chocolateBars..."--I could not get the test to pass. My last resort was to refresh the whole page and test it again. Worked like a charm; the test passed. Just want to give a heads up to the team so other peeps aren't stuck banging their heads against the desk! lol

IDE Issues

I have been working on the JavaScript Arrays lab and I saved my work multiple times before I closed IDE. I closed it because I felt maybe my changes weren't being registered. When I reopened it all my work was gone. Sooo frustrating.

Happened again...totally erased my saved work

screen shot 2018-12-09 at 3 58 15 pm

It happened again. This time, I thought that if I saved my work, I would be ok. While finishing the module and reading down to the bottom, I received the "Oops" error and it completely erased my work. I don't know. There is definitely a glitch in this system as it keeps happening in every module.

All of the functions that the module said to write were completely filled in and there was no yellow dot on top of this file. My work was in fact saved, but now it is gone. I am not trusting continuing to work in the IDE. I might have to create my own files in VS Code.

Readme and test files out of sync

A student pointed out that the README.md asks students to define a function destructivelyRemoveElementFromBeginningOfArray, but there is no test for this in the test files.

@aturkewi

Misleading instructions for removeElementFromEndOfArray function

The Readme file instructs the student for removeElementFromEndOfArray()

TODO: Define a function in arrays.js called removeElementFromEndOfArray that takes an array as its only argument and removes the last element. Your function should return the entire array, and it should not mutate the array.

However, the test is looking for the slice of the array instead of, the entire array

Using Arrow functions for this module

For this module...if you use arrow functions to complete this test it throws an

"AssertionError: expected 2 to deeply equal [ 'foo', 1 ]"

I found that changing the code back to the standard function declaration with a return array statement fixed the problem. But isn't that answer still correct (using arrow functions)?

Learn Test Timeout Issue

 arrays "before all" hook:                                           
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.                                                  
      at Object.done (node_modules/mocha-jsdom/index.js:70:7)            
      at process.nextTick (node_modules/jsdom/lib/jsdom.js:325:18)       
      at _combinedTickCallback (internal/process/next_tick.js:73:7)      
      at process._tickCallback (internal/process/next_tick.js:104:9) 

Registering as a pass in the lesson

I am just plain stuck

The errors aren't clear to me and I have been stuck on this for over a week. Someone helped earlier but it was not saved and nothing I try works. Can someone please get me out of this personal nightmare???

Buggy Labs & Tests

Chapters "Hoisting" and "JavaScript Arrays" have buggy labs. Fixing just the first issue gets you to "Passed Local Tests" in the Learn web interface, even though the Learn IDE shows fails or errors.

Layman translation: You can basically cheat these tests and move on to the next chapter without really fixing anything.

Doesn't really help those who actually want to learn. Admins please fix.

Problem with JavaScript Arrays lab

Here's the "TODO":

TODO: Define a function in arrays.js called destructivelyRemoveElementFromEndOfArray that takes an array as its only argument and removes the last element. Your function should return the entire array, and it should mutate the array.

The problem: the goal is to REMOVE the last element in the array. How can one "return the entire array" if the final element should be removed. The "TODO" should match the error code: "returns the array with the last element removed"

Complainy, I know, but this lesson is obscenely long.

I am having a serious organizational problem managing this lesson. It's difficult to go in between screens (applications). I'm also lucky to be on a retina mac! Can't imagine doing this one a 1080p screen.

This is the first lesson of all lessons (from the beginning of Javascript) that is this long. It is cumbersome and distracts from the learning concepts. I don't think arrays are any more complicated that scopes yet this lesson is just far less manageable. It should be divided into several lessons. It may be less elegant in the outline, but it will be easier for students to navigate and process. Sorry to complain-- this is a solvable problem for me bc i have a second monitor, but I think it will really negatively affect some people.

Folders won't load...

For some reason, the folders in CodePen won't load. The only one that will is array.js. I can't test my code ! I can't move on to the next lesson properly !

Unclear

is the array I am adding elements to the choclate bars or am I creating an array to alter within the arrays.js

I just feel unclear as to what my target focus is for the material I am learning for learning this material. I think that requires more extrapolation than the lesson intends. I notice that happens with previous lesson as well...

Is encouraging like - ok now go, but, its just like;
I should be editing chocolate bars var?

Like is not the content that is confusing to me from this - its the directing of my intention for applying that information that I find myself confused... Perhaps that is what I am to expect as an independent freelancer or from a bootcamp.. Its just a little daunting at hour two to feel so confused as to how to accomplish what is asked of me...

I should add its not the entire lesson; an I notice a striving to explain solution etc.. I just still feel like I did a lot better with the ok, lets try this one together - an then off you go.

Now I'm like ok... What is it I am destroying an element of?

array lab

ive been asking for help with the array lab for two days i received help on the first part but no help on the second part and its really starting to frustrate not because i dont understand but i not getting the answers to my questions

Trouble with functions tests

Keep getting errors on code for the destructive ones and don't know why.

function destructivelyAddElementToEndOfArray(array, added){
var complete= array.push(added);
return complete
}

Arrays trouble

I passed all my test, but i lack on the last one
it says to safely remove an item from the end of the array, but when i tried to
function removeElementFromEndOfArray(arrays){ var result = new Array() result = arrays.slice(0, arrays.lenght -1) return result }
it dosn't result what request from the test, what i have done wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.