what did I do wrong?
You will have to declare the count variable outside of your soloLoop() function…
The count variable is then a so-called GLOBAL Variable
Please read
#12 I have no clue about this
and define your soloLoop with NO parameter…
Although it is not taught in the track this should be ok as he uses with or without intention the socalled default parameters:
So it’s kind of interesting that this gives a syntax error instead of a custom error. Could you post this as copyable code? Or instead of count = 0 try just count and pass a value of 0 by using soloLoop(0)?
here you go
//Remember to make your condition true outside the loop!
var soloLoop = function( count = 0 ){
//Your code goes here!
while ( count < 1 ) {
console.log(“Looped once!”);
count++;
}
};
soloLoop(1);
Ok in this case count is 1 and 1 is not <1 so the loop won’t run even once.
been trying to fix that but nothing is working im changing the (count >1)
and the soloLoop to see if it worked
Well honest question do you know what you’re doing here?
var soloLoop = function( count = 0 ){
because if not I’d strongly recommend that you stick to:
var soloLoop = function( count){
And google “javaScript default parameters” later.
Than all you need to do would be to call the function with a value of 0. It’s often as tedious as it is helpful to go through the program step by step so maybe explain what you think you’re doing and compare it to what is actually done. Add console.logs when your unsure of a value of a variable at a certain point and just play around with the code a bit until you think you know what your doing. If the limitation of the exercise is hindering you maybe use repl.it or something comparable.labs
old news but this works
//Remember to make your condition true outside the loop!
var soloLoop = function(){
while(soloLoop) {
console.log(“Looped once!”);
soloLoop = false;
}
};
soloLoop(1);