- Notifications
You must be signed in to change notification settings - Fork6.7k
[PTMAD1018][PATRICIA DEFEZ]#698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Removed duplicated text
Extra Resources added
…with-teststarter-code-with-tests
…one" but the test is expecting for the string itself, i change the Readme file wich is the quck fix, but may be could be good to change the spec file to not confuse the student.
…tion-fixthe test are waiting for undefined but the description says false
…rd-fixfind-longest-word-little-fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Revisa las anotaciones que te he ido poniendo y tenlas presentes para próximos ejercicios, ánimo y sigue así! 🌵
return a; | ||
}else{ | ||
return b; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Elelse
puedes no ponerlo y dejar directamente elreturn b
,return
, además de devolver contenido, termina la ejecución de una función, con lo que si entra dentro delif
terminará la ejecución devolviendoa
y si no, devuelveb
words.forEach (function (element) { | ||
if (longest.length <= element.length){ | ||
longest = element; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Es correcto, peroforEach
no es la mejor elección para esto,for
mejor para estos casos
function calculAverage (numbersAvg){ | ||
for( i = 0; i < numbersAvg.length; i++){ | ||
resultSum += numbersAvg[i]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Podrías haber reutilizado la función de suma que declaraste justo arribasum
y dividir directamente el resultado, así te ahorras volver a escribir la misma función de antes:
function calcAvg(arr) { return sum(arr) / arr.length}
@@ -48,6 +105,16 @@ var wordsUnique = [ | |||
'bring' | |||
]; | |||
function uniqueArr (wordsUnique){ | |||
for( i = 0; i < wordsUnique.length; i++){ | |||
var word = wordsUnique[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
La creación de la variableword
debería ir fuera y luego la machacas dentro del bucle con cada palabra. Esto mejor así porque no creas una variable nueva cada vez, sino que reutilizas la misma
if(wordsUnique.indexOf(word)=== 0){ | ||
wordsUnique.pop(word); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Este ejercicio no es correcto, si te ha salido bien con el array que has introducido ha sido porque se te ha dado la condición para que te salga bien. Tienes errores en varios aspectos. No debes igualar el resultado deindexOf
a0
porque la coincidencia será siempre la primera posición del array, ya que es la posición 0 y la funciónpop
no recibe argumentos ya que siempre elimina el último elemento del array
wordToSearch = wordToSearch.toLowerCase(); | ||
var count = 0; | ||
for( i = 0; i< wordsCount.length; i++){ | ||
if (wordsCount.indexOf(wordToSearch, i) != -1){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Las igualaciones debes hacerlas estrictas, es decir!==
o===
en vez de!=
o==
count += 1; | ||
}else{ | ||
count = count; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No necesitas igualarcount = count
, estás dándole el mismo valor que ya tiene. Puedes ahorrarte ese bloqueelse
function greatestProduct (matrix){ | ||
var maxProduct = 0; | ||
for(i = 0; i === 19; i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
La triple igualación en la segunda condición delfor
no es necesaria, sobre todo si el límite lo hardcodeas tú misma (es decir, has escrito el número tú misma)
var maxProductIJ = 0; | ||
for (k = 1; k === 3; k++){ | ||
if (i-k < 0){ | ||
productUp = productUp * 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Por qué le asignas aproductUp
el mismo valor? ese tipo de condiciones se omiten, porque así se llena el código de líneas que no hacen nada
}else{ | ||
productRight *= matrix[i][j+k]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Diría que te sobran 3for
, de todas maneras recuerda que el producto de izquierda a derecha y de derecha a izquierda o el producto de arriba a abajo y de abajo a arriba dan el mismo resultado, así que seguro podrías quitarte 2 bloquesfor
IN PROGRES