Quiz help


#1

Q 1/ var answer = 1+“1”; what the value of variable “answer” why?
Q 2/ var one = 1; Does the following code produce an error if so why?
Q 3/ var 2tress = “tree” Does the following code produce an error if so why?
Q 4/ var ThisIsARealyRealyLongNameForAAvariable = 42; Does the following code produce an error if so why?
Q 5/ var $ =“all the money in the world!”; Does the following code produce an error if so why?


#2
  • A number plus a string.

JavaScript will coerce the number to a string and concatenate.

1 + "1"  =>  "1" + 1  =>  "11"
  • var one = 1;

Is a valid statement with no error.

  • var 2tress = “tree”

JavaScript variables may not begin with a number.

  • var ThisIsARealyRealyLongNameForAAvariable = 42;

No technical error but will give rise to lots of typos and make readability difficult, giving rise to more unintended errors.

  • var $ = “all the money in the world!”;

No error. $ is a valid variable name. It will run into some unexpected problems if a library such as jQuery is installed at load time. $ is the alias for jQuery. If your code suddenly defines it as "all the money in the world* then jQuery will be unloaded.


#3

Thanks for your great help there some few more I just need help every this is ok

Q 1 in three line writes some code that outputs(to the javascript console)all the number from one to 10,000.

Q 2 in the following there is a missing reserved word, indicated [missing word]
is that missing word if ?

[missing word] elementsByName( name) {
//some code
returen (element);
}

Q 3 same missing word

[missing word] (yourShipHasSailed == true ) {
out OfLuck = true;


#4


#5

What have you attempted so far?


#6

its just quiz Qs thanks for your help


#7

Where are your three lines of code that solve this question?


#8

console.log( 1,2,10000) ?


#9
// <-  1 2 10000

That’s all that will display in the console. Not the solution that is asked for. You need a loop


#10

how I need to write in three line


#11

Do not worry about how many lines, just try to write a solution that works.


#12

need to write this solution // <- 1 2 10000


#13

// <- 1 2 10000

console.log( 1,2,10000)

like this


#14

console.log() takes a comma separated list which will output with spaces instead of commas, just as shown above

1 2 10000

You need to build a loop.


#15

sorry I am new to javascript

console.log( 1 2 10000)


#16

Then it might be best to set the quizzes aside until you get some basics under your belt. Quizzes are not for teaching, but for testing what we know.

pythagorean-identity

Any idea what the above is about?


#17

no idea really I just …


#18

That’s okay. I was just making a point… You haven’t learned about trigonometric identities, it would seem. Would you take a trig quiz to start learning it? Not likely. Same applies here.


#19

console.log( <- 1 2 10000)


#20

Do you have a console open?

In Chrome, type the following into the location bar and enter it…

about:blank

It will open a blank browser window. Now press, Ctrl + Shift + J to open the JavaScript console.

At the prompt, > enter a JavaScript command and Enter to see the response.

Try,

console.log("Hello World!")

The output preceded by <-, which is the symbol I used above, indicates the response. It is not part of the input.

 > console.log("Hello World!")
   Hello World!
<- undefined

undefined is the response when there is no return from the method call. The log method has no return.


Addendum

Return vs Response

A function has no built in return, but there is no evading a response since a call was made. The processor has no choice but to await a response. Said response not forthcoming when a function has unloaded itself says, undefined.

There is always a response object in play whether or not there is a return value. Keep this distinction clearly in mind at all times and the way forward will be more smooth.


 > tenToTheFourth = []
<- []
 > for (var i = 0; i < 10000; i ++) {
    tenToTheFourth.push(i + 1);
   }
   console.log(tenToTheFourth.toString())
output

1, 2, 3, …, 9998, 9999, 10000

<- undefined

Give back the memory this uses by clearing the array…

tenToTheFourth = []