This forum is now read-only. Please use our new forums! Go to forums
Please help me on the below code. Also refer to the note in the description.
Note: Moreover, as soon as i start to type the while statement, it throws an error saying that, something went wrong, and nothing happens after that.
$rollcount =0; do { $roll = rand(1,6); $rollcount++; if($roll<6){ echo “
Dice rolled $roll
“; }else{ echo “You gotta six
“; } } while ($roll<=6); $verb = “were”; $last = “rolls”; if($rollcount = 1){ $verb = “was”; $last = “roll”; echo “There $verb $rollcount $last
“; }else{ echo “There $verb $rollcount $last
“; }Answer 55969a86e39efe29e000049c
The first thing you should know while writing PHP in codecademy is, it does not wait for you to complete your code. It updates the code immediately when you write it, so you gotta be careful when you write it.
This means that when you write white($var) { }
, the code automatically runs and it gets really annoying.
So what I do about this is, I give a different condition before writing the loop.
This means, when actually I want the loop to stop when $num < 3, I would put a different condition and then, when it is complete and the loop gets an end, I replace the condition.
while ($var)
{
$var = false;
//Now, I can write the actual code here without getting interrupted
//and when my job is over, I can delete the third line and change the
//condition for the white loop to get the correct result.
}
Another thing you can do is writing the code in any text editor like notepad, and then copying and pasting the code from notepad into codecademy. It is less time consuming and not complex like the previous one mentioned.
You’re welcome.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency