VB
Size: a a a
VB
И
A
PW
class MyFunc {
static sum(...data) {
return data.reduce((acc, e) => acc + e);
}
static divide(a, b) {
if (b === 0) {
return "You can not divide by zero.";
}
return a / b;
}
}
describe('MyFunc class', () => {
test('should add unlimited amount of numbers', () => {
expect(MyFunc.sum(1, 2, 3)).toBe(6);
expect(MyFunc.sum(1, 2, 5, 5, 10)).toBe(23);
});
test('should divide two numbers', () => {
expect(MyFunc.divide(6, 3)).toBe(2);
expect(MyFunc.divide(5, 0)).toBeInstanceOf(String);
});
});
VB
class MyFunc {
static sum(...data) {
return data.reduce((acc, e) => acc + e);
}
static divide(a, b) {
if (b === 0) {
return "You can not divide by zero.";
}
return a / b;
}
}
describe('MyFunc class', () => {
test('should add unlimited amount of numbers', () => {
expect(MyFunc.sum(1, 2, 3)).toBe(6);
expect(MyFunc.sum(1, 2, 5, 5, 10)).toBe(23);
});
test('should divide two numbers', () => {
expect(MyFunc.divide(6, 3)).toBe(2);
expect(MyFunc.divide(5, 0)).toBeInstanceOf(String);
});
});
"You can not divide by zero."
)VB
PW
new String
пробовалPW
VB
PW
DS
DS
S
S
S
DM
S
KS
S