0
Hello, Good Afternoon!
I am on a platform of studies in which exercises and tests are performed, the statement is:
Write the function can
SeAposentar
which receives by parameter the age, sex and years of social security contributions a person has, for example:podeSeAposentar(62, "F", 34) true
.The minimum retirement age for women is 60, while for men it is 65. In both cases, must have at least 30 years of contribution.
I made the following code:
function podeSeAposentar (idade, sexo, anosTrabalhados) {
if(anosTrabalhados >= 40) {
if(sexo == "F") {
if(idade >= 60) {
return true;
}
}
else if(sexo == "M") {
if(idade>= 65){
return true;
}
}
}
return false;
}
And the platform reports that:
Your solution worked, but points out the following error:
Objectives that were not met:
podeSeAposentar
makes comparisons against strings.
Could someone help me and why does this happen? Grateful!
Fernando, yes, and doing it this way or the other way the error makes comparisons against strings remains. What to do?
– Jeh
I think the most important thing is that you pass the link of this exercise... So it’s easier to analyze... I did what I could with what was written in the question. D
– fernandosavio
Fernando, this is it: https://mumuki.io/br/exercises/4511-programm_imperativa-logica-booleana-um-exercicio-sem-precedents
– Jeh
Their website has bug, I just posted my solution there and says: "the solution should declare a function podeSeAposentar". Run your code in the browser or https://codepen.io and test it yourself.
– fernandosavio
Yes, but as the platform of studies is there, even running ok on others in this would need to run kkk. :/
– Jeh
I just set a function
podeSeAposentar
, and the site ran every test on my function (which passed every test)... There’s an observation saying that I have to create a function called "podeSeAposentar". What I mean by that is what the website has bug, and maybe your question would never open if there was this bug. If your college degree or course depends on this platform, you should contact your teachers, otherwise I can only help you solve problems that really exist in your code. Their bug don’t know how to fix. :|– fernandosavio
Thanks for the tips and help Fernando!
– Jeh