educative.io

Explanation to the printing strings quiz

Hello!

I need help for this quiz. I understand the result of the first question but I don’t understand the result of the other 2.

Can someone explain?

Thanks,
Danilo


Type your question above this line.

Course: https://www.educative.io/collection/10370001/6289391964127232
Lesson: https://www.educative.io/collection/page/10370001/6289391964127232/5574006138732544

In the second output, we’ve initialized “O” using a simple variable instead of a short declaration operator whose value does not retain when we come out of its scope. So the output of the first quiz is GOG. But on re-calling the n function in the second quiz, we get GOO because we’ve not used the short declaration operator here.