Skip to content

Commit d48675a

Browse files
committed
Array.from()
1 parent c7b9ab2 commit d48675a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

arrayMethods/array-from.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const user = "rakin";
2+
console.log(Array.from(user));
3+
4+
const items = Array.from({ length: 120 }, (_, index) => {
5+
return index;
6+
});
7+
console.log(items);
8+
9+
const itemsPerPage = 14;
10+
const pages = Math.ceil(items.length / itemsPerPage);
11+
12+
const newItems = Array.from({ length: pages }, (_, index) => {
13+
const start = index * itemsPerPage;
14+
const tempItems = items.slice(start, start + itemsPerPage);
15+
return tempItems;
16+
});
17+
console.log(newItems);
18+
console.log(pages);

0 commit comments

Comments
 (0)