For the fist time ever I can’t follow Ivan’s logic. I see that the two textToshow values both both result in outputs with corresponding text. What I don’t understand is what rule determines when the variable is activated. I don’t know if my question even makes sense, but if anyone could explain to me how the variable acts, it would be greatly appreciated. To articulate my question in another way - why does output of the variable show first? Thanks.
I see that in one case Ivan has created a variable of textToShow with some text, and then another textToShow function with some different text, and has written alert(textToShow) below both of these. So I understand that there are two textToShow functions and both show as outputs. But I don‘t understand why it is necessary to write variable before one of them. Furthermore, I wrote a program as follows in Atom:
var textToshow=“hello world”;
You can see that alert(textToShow) is only written below the one without variable written before it, but it still results in two text alerts as outputs. Aaaahhhh. I dont understand what the variable is and how it works.
I’m not sure where to post this question. In the chapter 1 reading assignment it mentions that to put a \ as a character in a string you must do \\ and the two will collapse into one \. It gives the example: “A newline character is written like “\n”.” can be expressed: “A newline character is written like \”\n\"."
This is SUPER unlear to me. From the reading I would assume that it should be expressed as: “A newline character is written like “\\n”.” Why is there also a \ in front and another \ after the n?!? NOT explained in the reading at all.
Someone please explain?
oh wait, I get it… So the \ before the quote inside the quote prevents the quote from ending the string. And the quote before the end quote inside the string prevents THAT from also ending the string, and then the real end quote happens to end the string at the very end.
question 7 of the variables quiz makes NO sense. The modulo operator yields the remainder of dividing the first by the second. So 4 % 2 is the remainder of 4/2 (which is 2.0) so since there’s no decimal remainder, the result is 0. So the quiz question is (10+22) % 3 which is 32 % 3 which is the remainder of 32 / 3 (which comes to 10.6666666). So the answer should be 6666666666 to infinity, not the correct answer shown as 2! What am I missing here??? Please clarify!?