Length of Each Word in Array JavaScript (Algorithmic Project)

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 2

  • @nuwanthuduwage6869
    @nuwanthuduwage6869 2 года назад +1

    Hi DigiDev, Thank you for sharing your experience and knowledge. I have tried this with a recursive approach. Appreciate if you can review it.
    function stringLength(arr) {
    if (arr.length === 0) return arr;
    let output = [];
    let message = `${arr[0]}=${arr[0].length}`;
    output.push(message);
    return [...output, ...stringLength(arr.slice(1))];
    }