Arrays - Reading Assignment

1.- Allows to store multiple values un a single variable
2.- 0

1 Like

What do arrays allow us to do?
Arrays let you store multiple values (same type) in a single variable.

What index should you use in order to access the first element in an array?
Index 0

1 Like
  1. Arrays allow us to store list(s) of the same variable.
  2. Use brackets [0] or indexOf (“name of element”, positioned after value)
1 Like
  1. arrays allow to store multiple values in a single variable.
  2. the first element in an array is at index 0
1 Like
  1. Arrays store mulitple values
  2. index of first element is 0
1 Like
  1. Arrays allow us to store multiple values in a single variable. It stores a collection of variables of the same type.

  2. The index of 0 should be used to access the first element in an array.

1 Like
  1. What do arrays allow us to do?

Arrays allow us to hold multiple pieces of data, this data can be in a string, number etc it can also hold key/value pairs they are useful also as they hold the information in an indexed fashion that allows pieces of information to be called separately from the array.

  1. What index should you use in order to access the first element in an array?

Arrays are indexed and to access the first element, you should use 0 not 1.

1 Like
  1. What do arrays allow us to do?
    Arrays allow us to store multiple values in a single variable.

  2. What index should you use in order to access the first element in an array?
    The first element in an array has the index of 0.

1 Like

//A very interesting thing I discovered about an Array is that the elements do not have to be of the same type. Arrays allows us to store multiple elements of different types such as numbers, booleans, objects, functions, and strings, and you can call a function, boolean, number, object, and strings by just listing its number in brackets.

//Example

//Copy this array into your console and run:

var arr = [
1, false,
{
name: “Imhotep”,
address: ‘1003 Main Street’
},
function(name){
var greeting= "hello ";
console.log(greeting + name);
},
“hello”

];

//Now my array contains numbers, booleans, objects and functions and a string. I can call any element I wish by starting with zero as first element in array:

console.log([0]);
console.log([1]);
console.log([2]);
console.log([3]);
console.log([4]);

//or I can just call the array

console.log(arr);

//or I can call the function in the array by first calling the function as above and then invoking the function by using parenthesis and calling the name I want to use in the function.//

arr[3](arr[2].name);

//Your output from the console should give you this:

//[0]0: 0length: 1__proto__: Array(0)
//VM943:24 [1]0: 1length: 1__proto__: Array(0)
//VM943:25 [2]0: 2length: 1__proto__: Array(0)
//VM943:26 [3]0: 3length: 1__proto__: Array(0)
//VM943:27 [4]0: 4length: 1__proto__: Array(0)
//VM943:30 (5) [1, false, {…}, ƒ, “hello”]
//VM943:15 hello Imhotep
undefined

1 Like

1.) Arrays all us to hold different Values in a single variable .
2.)The array index always starts at “0” and is therefore we would use zero to get to acces the first element in an array.

1 Like
  1. What do arrays allow us to do?
    Lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type.

  2. What index should you use in order to access the first element in an array?
    The index would be zero [0]

1 Like
  1. Store multiple values in a single variable.

  2. It is 0.

1 Like
  1. Arrays allow us to store multiple values of the same type in one variable.

  2. “0”

1 Like
  1. Arrays allow you to store more than one value to a variable.
  2. This question doesn’t make sense to me but everyone else is saying you start with “zero” then “one” and finally “two”. This is a goofy way of counting for simple folk like me.
1 Like
  1. What do arrays allow us to do?
    Arrays let you store multiple values in a single variable. An array can hold many values under a single name, and you can access the values by referring to an index number.

  2. What index should you use in order to access the first element in an array?
    The index should be 0 (zero).

1 Like
  1. The Array object lets us store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

  2. [0]
    Example:
    var fruits = new Array( “apple”, “orange”, “mango” );

So in order to access the first element in an array, i simply write " fruits[0] "
(Second is fruits[1], third is fruits[2]).

1 Like
  1. Arrays allow us to store multiple values in a single variable.

  2. The first index in an array is 0 and is coded as: array[0]

1 Like
  1. " The Array object lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type." -tutorialspoint.com

  2. Array index starts from 0. " indexOf() Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. " -tutorialspoint.com

1 Like
  1. Arrays allow us to store multiple valuables in a single variable.
  2. 0 = first element in an array
  • What do arrays allow us to do?
    Arrays make it possible to store a list of values by using square brackets, separated by commas)

  • What index should you use in order to access the first element in an array?
    Since the first index of an array is zero, the first element is retrieved with listOfNumbers[0].

1 Like