-6 bytes
- Removed spaces around comparison
- Used len() instead of count
Minus 7
How many times can you subtract 7 from a given number?
Examples
numMinusSeven(1000) === 143;
numMinusSeven(100) === 15;
numMinusSeven(10) === 2;
function numMinusSeven(num) { return Math.ceil(num / 7) }
- function numMinusSeven(num) {
let arr = []while (num > 0) {num -= 7arr.push(num)}return arr.length- return Math.ceil(num / 7)
- }
const chai = require("chai"); const assert = chai.assert; chai.config.truncateThreshold = 0; const Test = require("@codewars/test-compat"); describe("Minus 7 test cases", function() { it("should test for 1000", function() { Test.assertEquals(numMinusSeven(1000), 143); }); it("should test for 100", function() { Test.assertEquals(numMinusSeven(100), 15); }); it("should test for 10", function() { Test.assertEquals(numMinusSeven(10), 2); }); });
- const chai = require("chai");
- const assert = chai.assert;
- chai.config.truncateThreshold = 0;
- const Test = require("@codewars/test-compat");
describe("Test", function() {- describe("Minus 7 test cases", function() {
- it("should test for 1000", function() {
- Test.assertEquals(numMinusSeven(1000), 143);
- });
it("should test for 100", function() {Test.assertEquals(numMinusSeven(100), 15);});it("should test for 10", function() {Test.assertEquals(numMinusSeven(10), 2);});- it("should test for 100", function() {
- Test.assertEquals(numMinusSeven(100), 15);
- });
- it("should test for 10", function() {
- Test.assertEquals(numMinusSeven(10), 2);
- });
- });