Skip to content

Commit 1e5585a

Browse files
authored
Create 1816-truncate-sentence.js
1 parent e66b777 commit 1e5585a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

1816-truncate-sentence.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {string} s
3+
* @param {number} k
4+
* @return {string}
5+
*/
6+
const truncateSentence = function(s, k) {
7+
const arr = s.split(' ')
8+
const sli = arr.slice(0, k)
9+
return sli.join(' ')
10+
};

0 commit comments

Comments
 (0)