When i run the code. It just displays the whole code! WHY?


#1


Why is the code being displayed when i run it?


Hey world! How y'all doing? function (){
// Write your do/while loop here!

do{
var x = false;
console.log("Hey world! How y'all doing? " + getToDaChoppa + "!"); x++;
}
while(x<1);
}!


var getToDaChoppa = function(){
  // Write your do/while loop here!
  var x = false;
  do{
      console.log("Hey world! How y'all doing? " + getToDaChoppa + "!"); x++;
      }
      while(x<1);
};

getToDaChoppa();


#2

console.log("Hey world! How y'all doing? " + getToDaChoppa + "!");

what is getToDaChoppa?it's a function.right?
so simply you are printing it :slight_smile:


#4

So is my condition for while right? or wrong? thank you.


#5

x = false and x < 1 are incompatible statements. you only need to compare x to an integer for javascript to determine whether it's true or false on its own!

var y = 1 // automatically true, y is equal to 1 
var x = 8 //true, x IS equal to 2

do {

//your code here :D

}
while ( y < x ); //js will ask itself if this condition is true on its own!

//watch out, this code will run forever ;u;

also, you are straight up logging the condition to console when you call the getToDaChoppa variable INSIDE of your loop!

var name = function() {
...
}

console.log name

/* outputs what you typed for the function to the console

var name = function() {
...
}
*/

#6

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