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