Skip to content

Instantly share code, notes, and snippets.

View maciejtrzcinski's full-sized avatar
👨‍🚀

Maciej Trzciński maciejtrzcinski

👨‍🚀
View GitHub Profile
['Poland', 'Germany', 'France', 'Russia', 'Japan'].sort();
// ["France", "Germany", "Japan", "Poland", "Russia"]
var objectArray = {a: 1, b: 2, c: 3};
for (const item in objectArray) {
console.log(item)
}
const array = [1,2,3,4,5,6];
array.forEach(function(item, index, array) {
console.log(`index ${index}, value ${item}, array ${array}`);
});
@maciejtrzcinski
maciejtrzcinski / while.js
Last active October 29, 2018 11:03
Looping over arrays - while
let index = 0;
const array = [1,2,3,4,5,6];
while (index < array.length) {
console.log(array[index]);
index++;
}