You will be given an array of different entries.
Along with this, the second argument gives the desired length for cutting.
You must cut words of this length from the words in the array.
You will be given an array of different entries.
Along with this, the second argument gives the desired length for cutting.
You must cut words of this length from the words in the array.
***If the length of the word in the array is greater than the given length, fill in the blanks with words!!!
function getStrings(strings, length){
let newArr = []
for(let i = 0; i < strings.length; i++){
if(strings[i].length >= length){
newArr[i] = strings[i].slice(0, length)
}else{
newArr[i] = strings[i].slice(0, length) + "*".repeat(length - strings.length)
}
}
return newArr
}
let result = getStrings(["Frontend", "Backend", "Flutter"], 15)
console.log(result)
// 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);
});
});