const numMinusSeven = function(num) { let youGoodBro = []; while (num > 0) { num -= 7; youGoodBro.push(num); } return youGoodBro.length; }
function numMinusSeven(num) {let youGoodBro = []while (num > 0) {num -= 7youGoodBro.push(num)}return youGoodBro.length- const numMinusSeven = function(num) {
- let youGoodBro = [];
- while (num > 0) {
- num -= 7;
- youGoodBro.push(num);
- }
- return youGoodBro.length;
- }
function numMinusSeven(num) { let youGoodBro = [] while (num > 0) { num -= 7 youGoodBro.push(num) } return youGoodBro.length }
- function numMinusSeven(num) {
let bbbbbbbbbb = []- let youGoodBro = []
- while (num > 0) {
- num -= 7
bbbbbbbbbb.push(num)- youGoodBro.push(num)
- }
return bbbbbbbbbb.length}- return youGoodBro.length
- }
const solution = s => { let total = 0; for (let i = 0; i < s.length; i++) { if (i < s.length - 1 && romanMap[s[i]] < romanMap[s[i + 1]]) { total += romanMap[s[i + 1]] - romanMap[s[i]]; i++; } else { total += romanMap[s[i]]; } } return total; }; const romanMap = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 };
var solution = (s) => {let total = 0;for(let index = 0; index < s.length; index++){if((s.length >= index + 1) && (romanMap[s[index]] < romanMap[s[index + 1]])){total += romanMap[s[index + 1]] - romanMap[s[index]];index ++;} else {total += romanMap[s[index]];}- const solution = s => {
- let total = 0;
- for (let i = 0; i < s.length; i++) {
- if (i < s.length - 1 && romanMap[s[i]] < romanMap[s[i + 1]]) {
- total += romanMap[s[i + 1]] - romanMap[s[i]];
- i++;
- } else {
- total += romanMap[s[i]];
- }
return total;- }
- return total;
- };
- const romanMap = {
- 'I': 1,
- 'V': 5,
- 'X': 10,
- 'L': 50,
- 'C': 100,
- 'D': 500,
- 'M': 1000
const getGrade = function(s1, s2, s3) { const avg = (s1 + s2 + s3) / 3; switch(true) { case (avg >= 90): return "A"; break; case (avg >= 80): return "B"; break; case (avg >= 70): return "C"; break; case (avg >= 60): return "D"; break; default: return "F"; } }
function getGrade (s1, s2, s3) {let avg = (s1 + s2 + s3) / 3;if (avg >= 90) {return "A"- const getGrade = function(s1, s2, s3) {
- const avg = (s1 + s2 + s3) / 3;
- switch(true) {
- case (avg >= 90):
- return "A";
- break;
- case (avg >= 80):
- return "B";
- break;
- case (avg >= 70):
- return "C";
- break;
- case (avg >= 60):
- return "D";
- break;
- default:
- return "F";
- }
else if (avg >= 80) {return "B"}else if (avg >= 70) {return "C"}else if (avg >= 60) {return "D"}else {return "F"}- }
const chai = require("chai"); const assert = chai.assert; const Test = require("@codewars/test-compat"); describe("Solution", function() { it("Hey! Good job!", function() { Test.assertEquals(getGrade(69, 94, 31), "D"); Test.assertEquals(getGrade(95, 89, 92), "A"); Test.assertEquals(getGrade(68, 91, 95), "B"); Test.assertEquals(getGrade(0, 65, 13), "F"); }); });
- const chai = require("chai");
- const assert = chai.assert;
- const Test = require("@codewars/test-compat");
- describe("Solution", function() {
- it("Hey! Good job!", function() {
- Test.assertEquals(getGrade(69, 94, 31), "D");
- Test.assertEquals(getGrade(95, 89, 92), "A");
- Test.assertEquals(getGrade(68, 91, 95), "B");
- Test.assertEquals(getGrade(0, 65, 13), "F");
- });
- });
const reverseGear = word => (str === "") ? "" : reverseString(str.substr(1)) + str.charAt(0);
function reverseGear(word){if (str === "")return "";elsereturn reverseString(str.substr(1)) + str.charAt(0);}- const reverseGear = word => (str === "") ? "" : reverseString(str.substr(1)) + str.charAt(0);
Refactored a solution/code snippet