From f4cd73a766b53de63993a5d42b0acc6a3acc5b22 Mon Sep 17 00:00:00 2001 From: VijaytParmar <43690392+VijaytParmar@users.noreply.github.com> Date: Sun, 3 Apr 2022 21:00:46 +0530 Subject: [PATCH] to fix truncateWords function not work properly In truncateWords function there is a one mistake, if(num > arr.length) => This will not work properly instead if(num < arr.lenght) => this will work properly --- lib/string.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/string.js b/lib/string.js index 5f079766..f14c5450 100644 --- a/lib/string.js +++ b/lib/string.js @@ -717,7 +717,7 @@ helpers.truncateWords = function(str, count, suffix) { var num = Number(count); var arr = str.split(/[ \t]/); - if (num > arr.length) { + if (num < arr.length) { arr = arr.slice(0, num); }