Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Write a function to truncate a string to a certain number of words.

Instructions

Truncate a string to a certain number of words.

Challenges (0/2 done)

  • truncateWithWordLimit("JavaScript is simple", 3) returns "JavaScript is simple".
  • truncateWithWordLimit("Codedamn is the best place to learn to code", 5) returns "Codedamn is the best place".
const str = 'JavaScript is simple but not easy to master';
const wordLimit = 3

function truncateWithWordLimit(str, wordLimit) {
    // write your solution here

    return
}

console.log(`Truncated string: ${truncateWithWordLimit(str, wordLimit)}`)