Tell us what’s happening:
I have completed the challenge Basic Algorithm Scripting: Truncate a String with the following code:
But when i click on Run The tests it does not passes the test. Do I need to use another method or try a different approach?
Your code so far
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
var str1="";
var str2="...";
var str3="";
function truncateString(str, num) {
// read the string character by character
for (var i=0; i<num;i++) {
str1 += str[i]
}
str3 = str1+str2
// console.log(str3)
return str3;
}
truncateString("Absolutely Longer", 2)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
.
Challenge: Truncate a String
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/truncate-a-string