function getGrade (s1, s2, s3) { let avg = (s1 + s2 + s3) / 3; if (avg >= 90) { return "A" } if (avg >= 80) { return "B" } if (avg >= 70) { return "C" } if (avg >= 60) { return "D" } return "F"; }
- function getGrade (s1, s2, s3) {
- let avg = (s1 + s2 + s3) / 3;
- if (avg >= 90) {
- return "A"
- }
else if (avg >= 80) {- if (avg >= 80) {
- return "B"
- }
else if (avg >= 70) {- if (avg >= 70) {
- return "C"
- }
else if (avg >= 60) {- if (avg >= 60) {
- return "D"
- }
else {return "F"}- 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");
- });
- });
function removeSymbols(str) { let newStr = ""; // list of possible symbols const symbols = "@#$%&=^*()-_=+<>/[]|?!,.£`".split(""); // iterate through each characters in the input str, ignore character if it is a symbol for (const char of str){ if (!symbols.includes(char)){ newStr += char; } } // return new string with no symbols return (newStr); }
- function removeSymbols(str) {
const regEx = /[&%!@=\*£]/g;const newStr = str.replaceAll(regEx, "");- let newStr = "";
- // list of possible symbols
- const symbols = "@#$%&=^*()-_=+<>/[]|?!,.£`".split("");
- // iterate through each characters in the input str, ignore character if it is a symbol
- for (const char of str){
- if (!symbols.includes(char)){
- newStr += char;
- }
- }
- // return new string with no symbols
- return (newStr);
- }