Challenges, Tips & Tricks & Tutorials

# JavaScript Quiz – can divide assignment operator work in one go Contents

## Divide Assignment Operator

In javascript, there are many operator in which divide assignment operator perform two operation in one go. Because it divide the value and then it’s value stored in the variable.

Basic Syntax of Divide Assignment Opetator

``/=``

## JavaScript Question

In this javascript quiz, find out can divide assignment operator work in one go because it divide and then assign the value.

First, we declare a variable num using let keyword and assign a number 10 to it.

``let num = 10;``

Now, we use the divide assignment and print the value at the same time with the help of console log.

``````console.log(num /= 2);
// output => ? ?

console.log(num /= 0);
// output => ? ?``````

Any idea what should be the output of above javascript code statement.

## JavaScript Quiz Test

Here is the full javascript code snippet for you to solve.

``````let num = 10;

console.log(num /= 2);
// output => ? ?

console.log(num /= 0);
// output => ? ?

// Made with ❤️, by @jsstartup``````

## Explanation

Now, you know the answer is 5, Infinity. But why the second output is Infinity. Let me explain.

So, for the first console log output, it’s clear that num is divide by 2 and output value assignment to num. That’s why the output is 5.

Now, that’s an obvious output that whenever a value is divided by 0 then it leads to Infinity.

At last, That’s why we get an answer “5, Infinity“.

Let me know in the comment section, what you think about it.

I hope you understand the concept and logic behind it.

But wait, i have something more for you –

## Conclusion

To participate in our javascript quiz or challenges, tutorial, tips & tricks make sure to join our jsstartup newsletter. So, you can able to participate in our daily challenges & learn the javascript concept.

And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page

If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.

0 Shares