our goal here is to build, piece by piece, to a formula that will accept multiple points.
after this, the goal will be to define the visible area of the graph based on the min/max in the parameters.
function drawGraph(position) {
const width = 5;
const height = 5;
const arr = [];
for (let i = 0; i < height; i++) {
arr[i] = [];
};
arr.forEach((row, idx) => {
for (let i = 0; i < width; i++) {
row.push(" ");
}
(idx < width -1) ?
row[0] = "|" :
row[0] = "+";
})
let count = +1;
while (count < width) {
arr[width - 1][count] = "-";
count++;
}
arr[height - position.y - 1][position.x] = "*";
return arr;
}
const chai = require("chai");
const assert = chai.assert;
chai.config.truncateThreshold = 0;
const Test = require("@codewars/test-compat");
describe("Solution", function() {
it("should test for something", function() {
// Test.assertEquals({x: 2, y: 3},
[['|', ' ', ' ', ' ', ' '],
['|', ' ', '*', ' ', ' '],
['|', ' ', ' ', ' ', ' '],
['|', ' ', ' ', ' ', ' '],
['+', '-', '-', '-', '-']]
});
});
return the cumulative letter grade based on the average of the student's percent scores.
60 => "F"
70 => "D"
80 => "C"
90 => "B"
=90 => "A"
function getGrade (s1, s2, s3) {
let avg = (s1 + s2 + s3) / 3;
if (avg >= 90) {
return "A"
}
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");
});
});
our first test of icodethis Kumite for pro members.
given a string (str), you should begin by removing the symbols.
Example:
"y&%ou sho!!!uld! no@t e@at yell==ow sn**ow" =>
"you should not eat yellow snow"
function removeSymbols(str) {
const regEx = /[&%!@=\*£]/g;
const newStr = str.replaceAll(regEx, "");
return (newStr);
}
// Since Node 10, we're using Mocha.
// You can use `chai` for assertions.
const chai = require("chai");
const assert = chai.assert;
// Uncomment the following line to disable truncating failure messages for deep equals, do:
// chai.config.truncateThreshold = 0;
// Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
// Uncomment the following to use the old assertions:
const Test = require("@codewars/test-compat");
describe("Solution", function() {
it("should test for something", function() {
Test.assertEquals(removeSymbols("y&%ou sho!!!uld! no@t e@at yell==ow sn**ow"), "you should not eat yellow snow");
Test.assertEquals(removeSymbols("whe%%re ar*@e th£e birds"), "where are the birds");
Test.assertEquals(removeSymbols("b@an@anas are fu£@ll of potassi&%&um"), "bananas are full of potassium");
// assert.strictEqual(1 + 1, 2);
});
});