|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
357 bytes
|
| Line | |
|---|
| 1 | function fill(array, value, start = 0, end = array.length) {
|
|---|
| 2 | const length = array.length;
|
|---|
| 3 | const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|---|
| 4 | const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|---|
| 5 | for (let i = finalStart; i < finalEnd; i++) {
|
|---|
| 6 | array[i] = value;
|
|---|
| 7 | }
|
|---|
| 8 | return array;
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | export { fill };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.