-1
Good afternoon! I’m tending to solve the exercise below but I’m not getting it, I set the code but it didn’t work, could help me?
In a gym there is a register of several users containing the following information: name, age and height. And to perform a particular training, there are some requirements: To be 18 years old or older and to have a height equal to or greater than 1.70.
Create a function called highAlt that returns true (true) if it meets the requirements, and false (false) otherwise. In this function you will receive a parameter that will be an array, containing in the first position the name, second position the age of the student and in the third containing the height in Centimeters.
Example
maiorAlto(["Aluno incrível", 18, 170]) // retorna true
maiortAlto(["Aluno baixo", 17, 150]) // retorna false
Tips:Remember that to create a function we use the word Function In the information array, the user’s age comes first, according to the height (which is in centimeters) To access the position of an array hit put the name followed by square brackets: array[1]
Down with the code I made:
var usuario2 = ['Pessoa do Pântano', 39, 198]
var usuario3 = ['Homem da Lua Virada', 21, 149]
var usuario4 = ['Pequena Paulistana', 18, 171]
var usuario5 = ['Menino da Porteira', 13, 142]
function maiorAlto(["nome", 18, 170]) {
for (var i = 0; i < maiorAlto.length; i++) {
if (usuario1[2] == 18 && usuario1[3] == 170)
return true; false
if (usuario2[2] == 18 && usuario2[3] == 170)
return true; false
if (usuario3[2] == 18 && usuario3[3] == 170)
return true; false
if (usuario4[2] == 18 && usuario4[3] == 170)
return true; false
if (usuario5[2] == 18 && usuario5[3] == 170)
return true; false
}
}
This answers your question? Problem Solving in Javascript
– Leo Letto