Compare commits

..

No commits in common. "4cb2fa66b9d773b656f5827c4fdd85dc99006a20" and "f0c8df60817495c72c7a0aac497cc6f0025dbfc0" have entirely different histories.

8 changed files with 28 additions and 46 deletions

View File

@ -1,9 +1,9 @@
const removeFromArray = function(array, ...remove) {
remove.forEach(element => {
let findIndexElement = array.findIndex(x => x === element);
let findIndexElement = array.findIndex(x => x == element);
if (findIndexElement >= 0) {
let saveArray = [];
for (let i = 0, arrayLength = array.length; i < arrayLength - findIndexElement - 1; i++) {
for (let i = 0; i < array.length - findIndexElement; i++) {
saveArray.push(array.pop());
}
array.pop();
@ -15,5 +15,7 @@ const removeFromArray = function(array, ...remove) {
return array;
};
removeFromArray([1, 2, 3, 4], 7, 2);
// Do not edit below this line
module.exports = removeFromArray;

View File

@ -13,13 +13,13 @@ describe('removeFromArray', () => {
test('ignores non present values, but still works', () => {
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
});
test('can remove all values', () => {
test.skip('can remove all values', () => {
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
});
test('works with strings', () => {
test.skip('works with strings', () => {
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
});
test('only removes same type', () => {
test.skip('only removes same type', () => {
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
});
});

View File

@ -1,13 +1,5 @@
const sumAll = function(a, b) {
if (a < 0 || b < 0 || typeof(a) != "number"|| typeof(b) != "number") {
return "ERROR";
}
let c, sum = 0;
for ((a > b) ? (i = b, c = a)
: (i = a, c = b); i <= c; i++) {
sum += i;
}
return sum;
const sumAll = function() {
};
// Do not edit below this line

View File

@ -4,19 +4,19 @@ describe('sumAll', () => {
test('sums numbers within the range', () => {
expect(sumAll(1, 4)).toEqual(10);
});
test('works with large numbers', () => {
test.skip('works with large numbers', () => {
expect(sumAll(1, 4000)).toEqual(8002000);
});
test('works with larger number first', () => {
test.skip('works with larger number first', () => {
expect(sumAll(123, 1)).toEqual(7626);
});
test('returns ERROR with negative numbers', () => {
test.skip('returns ERROR with negative numbers', () => {
expect(sumAll(-10, 4)).toEqual('ERROR');
});
test('returns ERROR with non-number parameters', () => {
test.skip('returns ERROR with non-number parameters', () => {
expect(sumAll(10, "90")).toEqual('ERROR');
});
test('returns ERROR with non-number parameters', () => {
test.skip('returns ERROR with non-number parameters', () => {
expect(sumAll(10, [90, 1])).toEqual('ERROR');
});
});

View File

@ -1,14 +1,5 @@
const leapYears = function(year) {
if (year % 400 == 0) {
return true;
}
if (year % 100 == 0) {
return false;
}
if (year % 4 == 0) {
return true;
}
return false;
const leapYears = function() {
};
// Do not edit below this line

View File

@ -4,19 +4,19 @@ describe('leapYears', () => {
test('works with non century years', () => {
expect(leapYears(1996)).toBe(true);
});
test('works with non century years', () => {
test.skip('works with non century years', () => {
expect(leapYears(1997)).toBe(false);
});
test('works with ridiculously futuristic non century years', () => {
test.skip('works with ridiculously futuristic non century years', () => {
expect(leapYears(34992)).toBe(true);
});
test('works with century years', () => {
test.skip('works with century years', () => {
expect(leapYears(1900)).toBe(false);
});
test('works with century years', () => {
test.skip('works with century years', () => {
expect(leapYears(1600)).toBe(true);
});
test('works with century years', () => {
test.skip('works with century years', () => {
expect(leapYears(700)).toBe(false);
});
});

View File

@ -1,10 +1,7 @@
const convertToCelsius = function(deg) {
return Math.round((deg - 32) * (5/9) * 10) / 10;
const convertToCelsius = function() {
};
const convertToFahrenheit = function(deg) {
return Math.round((deg * (9/5) + 32) * 10) / 10;
// x °C ≘ (x ×9/5+ 32) °F
const convertToFahrenheit = function() {
};
// Do not edit below this line

View File

@ -4,22 +4,22 @@ describe('convertToCelsius', () => {
test('works', () => {
expect(convertToCelsius(32)).toEqual(0);
});
test('rounds to 1 decimal', () => {
test.skip('rounds to 1 decimal', () => {
expect(convertToCelsius(100)).toEqual(37.8);
});
test('works with negatives', () => {
test.skip('works with negatives', () => {
expect(convertToCelsius(-100)).toEqual(-73.3);
});
});
describe('convertToFahrenheit', () => {
test('works', () => {
test.skip('works', () => {
expect(convertToFahrenheit(0)).toEqual(32);
});
test('rounds to 1 decimal', () => {
test.skip('rounds to 1 decimal', () => {
expect(convertToFahrenheit(73.2)).toEqual(163.8);
});
test('works with negatives', () => {
test.skip('works with negatives', () => {
expect(convertToFahrenheit(-10)).toEqual(14);
});
});