• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dApY3112 / software-testing-assignment-part2 / 20169881981

12 Dec 2025 02:28PM UTC coverage: 93.827% (-4.2%) from 98.014%
20169881981

push

github

ad1426
Merge branch 'main' of https://github.com/dApY3112/software-testing-assignment-part2

117 of 155 branches covered (75.48%)

Branch coverage included in aggregate %.

947 of 979 relevant lines covered (96.73%)

2.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.7
/src/slice.js
1
/**
2✔
2
 * Creates a slice of `array` from `start` up to, but not including, `end`.
2✔
3
 *
2✔
4
 * **Note:** This method is used instead of
2✔
5
 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
2✔
6
 * returned.
2✔
7
 *
2✔
8
 * @since 3.0.0
2✔
9
 * @category Array
2✔
10
 * @param {Array} array The array to slice.
2✔
11
 * @param {number} [start=0] The start position. A negative index will be treated as an offset from the end.
2✔
12
 * @param {number} [end=array.length] The end position. A negative index will be treated as an offset from the end.
2✔
13
 * @returns {Array} Returns the slice of `array`.
2✔
14
 * @example
2✔
15
 *
2✔
16
 * var array = [1, 2, 3, 4]
2✔
17
 *
2✔
18
 * _.slice(array, 2)
2✔
19
 * // => [3, 4]
2✔
20
 */
2✔
21
function slice(array, start, end) {
5✔
22
  let length = array == null ? 0 : array.length
5!
23
  if (!length) {
5✔
24
    return []
×
25
  }
×
26
  start = start == null ? 0 : start
5!
27
  end = end === undefined ? length : end
5!
28

5✔
29
  if (start < 0) {
5✔
30
    start = -start > length ? 0 : (length + start)
5!
31
  }
×
32
  if (end < 0) {
5✔
33
    end += length
×
34
  }
×
35
  length = start > end ? 0 : ((end - start) >>> 0)
5✔
36
  start >>>= 0
5✔
37

5✔
38
  let index = -1
5✔
39
  const result = new Array(length)
5✔
40
  while (++index < length) {
5✔
41
    result[index] = array[index + start]
9✔
42
  }
9✔
43
  return result
5✔
44
}
5✔
45

5✔
46
export default slice
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc