Javascript quiz #1 solution 1

in javascriptquiz •  4 years ago 

Q1

  1. window.alert(window.alert("hello"));

Ans1. At First it it will display alert a message with hello and after clicking ok button it will display an alert box with message undefined.

Q2. window.alert( );
Ans2: display alert box with blank message.

Q3. window.alert(console.log("@double-u has more 2700000 "));
Ans3: alert box with undefined messsage and output in console @double-u has more 2700000

Q4 . var x = 1;
console.log("window.alert( x++ )");
Ans4. output in console window.alert( x++ )

Q5 console.log(@afrog is attending the quiz);
Ans 5: Syntax error because no variable with name @afrog is attending the quiz

Q6 {

           var x = 20 ;
            for(i=0; i<x ; i++)
            { 
              console.log("x is now " + x ); 
            }

}

Ans 6: output in console x is now 20 20 times

Q7:what will be the output if in question number 6 after console.log("x is now " + x ); the next line of code is added as :
a) x--;
b) x= x-20;
c) x=x-i;
d) x= x++ + --x;

Ans 7:
at x--
output will be
x is now 20
x is now 19
x is now 18
x is now 17
x is now 16
x is now 15
x is now 14
x is now 13
x is now 12
x is now 11
because at x=11 i is greater loop will terminate

at x=x-20
output x is now 20

at x=x-i;
Output will be
x is now 20
x is now 20
x is now 19
x is now 17
x is now 14
x is now 10

x= x++ + --x
x is now infinity

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  

@zaid you are right for most of your ansers and here are my corrections.

Quesyion No 1 part 5 , we cant say that no variable defines by the name as it is a complete string and plus even if you wll try to define :
var @afrog = 20;
It will give you a syntax error as you can't define a variable with '@' in the start.

And in the last part i.e 7) d)
We will see the infinity message as well but before that x will be shown different values as well.

I will ask you to run this part d) in the browser for one minute and then you can tell me what did you see.

Thanks for participating once again.
Keep it up and keep practising.

good attempt to the quiz @mohdzaid. Kindly wait for sometime for the rewards from @blurtutorials.

Thank You.