Skip to content

Conversation

@anabalf
Copy link

@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) {

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
}

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;

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

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

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