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

joniflink / comp-se-200-assignment-part2 / 19835145086

01 Dec 2025 07:38PM UTC coverage: 88.356% (+88.4%) from 0.0%
19835145086

push

github

web-flow
Update package.json

36 of 49 branches covered (73.47%)

Branch coverage included in aggregate %.

222 of 243 relevant lines covered (91.36%)

1.98 hits per line

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

77.78
/src/.internal/createMathOperation.js
1
import baseToNumber from './baseToNumber.js'
1✔
2
import baseToString from './baseToString.js'
1✔
3

1✔
4
/**
1✔
5
 * Creates a function that performs a mathematical operation on two values.
1✔
6
 *
1✔
7
 * @private
1✔
8
 * @param {Function} operator The function to perform the operation.
1✔
9
 * @param {number} [defaultValue] The value used for `undefined` arguments.
1✔
10
 * @returns {Function} Returns the new mathematical operation function.
1✔
11
 */
1✔
12
function createMathOperation(operator, defaultValue) {
1✔
13
  return (value, other) => {
1✔
14
    if (value === undefined && other === undefined) {
9!
15
      return defaultValue
×
16
    }
×
17
    if (value !== undefined && other === undefined) {
9!
18
      return value
×
19
    }
×
20
    if (other !== undefined && value === undefined) {
9!
21
      return other
×
22
    }
×
23
    if (typeof value === 'string' || typeof other === 'string') {
9✔
24
      value = baseToString(value)
2✔
25
      other = baseToString(other)
2✔
26
    }
2✔
27
    else {
7✔
28
      value = baseToNumber(value)
7✔
29
      other = baseToNumber(other)
7✔
30
    }
7✔
31
    return operator(value, other)
9✔
32
  }
9✔
33
}
1✔
34

1✔
35
export default createMathOperation
1✔
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