Bad practices


Why is this code being marked as wrong? Is codecademy teaching bad practices such as actually putting floating values instead of dynamically calculating the division which is the superior choice?

var computerChoice = Math.random();
if(computerChoice > 0 && computerChoice < 1/3)
    computerChoice = "rock";
else if(computerChoice > 1/3 && computerChoice < 2/3)
    computerChoice = "paper";
    computerChoice = "scissors";


I think it's safe to say that most people who do this course have little or no prior understanding of programming.

Therefore I don't think it is fair to expect Codecademy to teach all the best practices while the students are still trying to grasp the concept of how coding works. I believe it is more beneficial to strictly show the student what is happening. i.e; if the random number is between 0 and 0.33 make it a rock, 0.33 - 0.66 will be a paper etc. And then once the student feels they understand it then they will be able to practice and learn how to improve.

It's like trying to teach a kindergartener how to spell words before teaching them their abc's.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.