Format in value
value with fixed decimal places numberOfPlaces
if it is a number, if it's not - return input as is.
function formatIfNumber(value, numberOfPlaces) {
return "";
}
// 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(1 + 1, 2);
// assert.strictEqual(1 + 1, 2);
assert.strictEqual(formatIfNumber("word", 4), "word");
assert.strictEqual(formatIfNumber(8.141516, 4), 8.1415);
assert.strictEqual(formatIfNumber(2, 4), 2);
assert.strictEqual(formatIfNumber(15.34, 4), 15.34);
assert.strictEqual(formatIfNumber(15.34, 1), 15.3);
});
});