From 91bd9064d148fbbe2eb5564e2d3c1d062c7a166f Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez <98057819+alejandroh9800@users.noreply.github.com> Date: Mon, 5 Sep 2022 01:38:07 -0700 Subject: [PATCH] Added an iterative approach with (for of) --- getTheTitles/getTheTitles.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/getTheTitles/getTheTitles.js b/getTheTitles/getTheTitles.js index 38288ab..2f6fed4 100644 --- a/getTheTitles/getTheTitles.js +++ b/getTheTitles/getTheTitles.js @@ -3,3 +3,14 @@ const getTheTitles = function(array) { }; module.exports = getTheTitles; + + +const getTheTitles = function (array) { + let titles = []; + + for (const element of array) titles.push(element.title); + + return titles; +}; + +module.exports = getTheTitles