6/11 solo flight


#1

what did I do wrong?


#2

@lightattheend,

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
http://discuss.codecademy.com/t/12-i-have-no-clue-about-this/21017/2?u=leonhard_wettengmx_n
and define your soloLoop with NO parameter...


#3

Although it is not taught in the track this should be ok as he uses with or without intention the socalled default parameters:
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Functions/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)?


#4

here you go :confused:

//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);


#5

Ok in this case count is 1 and 1 is not <1 so the loop won't run even once.


#7

been trying to fix that but nothing is working im changing the (count >1)
and the soloLoop to see if it worked


#8

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 labs repl.it or something comparable.


#10

old news but this works :slight_smile:

//Remember to make your condition true outside the loop!

var soloLoop = function(){
while(soloLoop) {
console.log(“Looped once!”);
soloLoop = false;
}

};

soloLoop(1);