Skip to content

[PTREMOTE] - Ana Pais#3843

Open
anabalf wants to merge 5 commits intoironhack-labs:masterfrom
anabalf:master
Open

[PTREMOTE] - Ana Pais#3843
anabalf wants to merge 5 commits intoironhack-labs:masterfrom
anabalf:master

Conversation

@anabalf
Copy link
Copy Markdown

@anabalf anabalf commented Jun 7, 2023

No description provided.

}
let longestWord;
for (let i = 0; i < words.length; i++) {
if (!longestWord || words[i].length > longestWord.length) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lo que podemos hacer aqui para remover ese !longestWord es inicializar la palabra como un string vacio

function findLongestWord(words) {
  if (words.length === 0) {
    return null;
  }
  let longestWord = "";
  for (let i = 0; i < words.length; i++) {
    if (words[i].length > longestWord.length) {
      longestWord = words[i]
    }
  }
  return longestWord
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asi podemos remover la priemra ocndicion del if y funcionaria sin problema :D

if(wordsArr.length === 0) {
return null;
}
let sum = wordsArr.join('').length;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Excelente forma de resolverlo

@iPoolito
Copy link
Copy Markdown

Excelente trabajo Ana! 🚀 la iteracion Bonus 3, podria ser algo asi

function sum(arrElements) {
  let sum = 0

  for (element of arrElements) {
    if (typeof element === 'object') {
      throw new Error(`Unsupported data type sir or ma'am`)

    }
    if (typeof element === 'string') {
      sum += element.length
    } else {

      sum += element
    }
  }
  return sum
}

@stale
Copy link
Copy Markdown

stale bot commented Jul 15, 2023

This pull request has been automatically marked as stale because it didn't have any recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants