Utwórz tablicę z liczbą JS
var foo = new Array(45); // create an empty array with length 45
Bad Booby
var foo = new Array(45); // create an empty array with length 45
//create an array like so:
var colors = ["red","blue","green"];
//you can loop through an array like this:
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
var events = [
{
userId: 1,
place: "Wormholes Allow Information to Escape Black Holes",
name: "Check out this recent discovery about workholes",
date: "2020-06-26T17:58:57.776Z",
id: 1
},
{
userId: 1,
place: "Wormholes Allow Information to Escape Black Holes",
name: "Check out this recent discovery about workholes",
date: "2020-06-26T17:58:57.776Z",
id: 2
},
{
userId: 1,
place: "Wormholes Allow Information to Escape Black Holes",
name: "Check out this recent discovery about workholes",
date: "2020-06-26T17:58:57.776Z",
id: 3
}
];
console.log(events[0].place);
//create an array like so:
var colors = ["red"];
//can add an element to array like this:
colors.push("blue");
//loop through an array like this:
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
const person = { firstName: "John" lastName:"Lee" age: "11"}
const fruits = [
{id: 1, name: 'Apple'},
{id: 2, name: 'Banana'},
{id: 3, name: 'Orange'},
]
let fruits = ['Apple', 'Banana']
console.log(fruits.length)
// 2