Skip to content

Latest commit

 

History

History
261 lines (143 loc) · 4.14 KB

book1-chap1-quiz.md

File metadata and controls

261 lines (143 loc) · 4.14 KB

Quiz - YDKJS: Up & Going 1/3

Chapter 1: Into Programming

Self-Evaluation

Section: Code


1. What's a program?

your answer here

2. What's a computer language?

your answer here

3. What's a variable?

your answer here

4. What's a statement?

your answer here

5. From the statement a = b * 2 identify its parts (literals, variables, operators).

your answer here

6. What's an expression?

your answer here

7. How many expressions can you indentify from the statement a = b * 2;?

your answer here

8. What's the difference between interpreted and compiled code?

your answer here

9. Is JavaScript interpreted or compiled? Explain why.

your answer here

Section: Try It Yourself


10. Output Exercises.

Consider: var a = 1;

Write the code to:

10.1. print a in the console

// your code here

10.2. show a in a popup

// your code here

11. Input Exercises.

Code challenge:

Ask the user's name with a prompt message "Please, type your username" and store it in a variable username, then log the value in the console.

Solution:

// your code here

Section: Operators


12. Complete the sentence:

JavaScript has both u___ and b___ operators, and one special t___ operator

your answer here

13. Operators types.

Name the types of operators you know, and give some basic examples.

your answer here

Section: Values & Types


14. Name JavaScript built-in types aka as primitive values.

your answer here

15. What's coercion in JS?

your answer here

16. Explain the difference between implicit and explicit coercion in JS. Give examples.

your answer here

Section: Code Comments


17. What are the two types of comments in JS? Give examples.

your answer here

18. Why is it important to comment code?

your answer here

Section Variables


19. Does JavaScript use Static or Weak typing?

your answer here

20. Describe static typing aka type enforcement.

your answer here

21. Describe weak typing aka dynamic typing.

your answer here

22. Name some conventions to write constants in JS.

your answer here

Section: Blocks


23. Is this valid code in JS?
var amount = 100;

{
  amount = amount * 2;
  console.log(amount)
}

your answer here

Section: Conditionals


24. Write a block of code to validate if a variable number is less than 10 to log one digit, log two digits otherwise.

Solution:

// your code here

Section: Loops


25. Write a block of code to log numbers from 0-9 using while, do-while and for loops.

while solution:

// your code here

do-while solution:

// your code here

for solution:

// your code here
26. What are the three clauses for a for loop?

your answer here

Section: Functions


27. What's a function?

your answer here

28. Write a function sum that receives two numbers as arguments and returns the sum of both.

Solution:

// your code here
29. What's scope in JS?

your answer here

30. Answer true or false for the following statements:

Consider:

function outer() {
  var a = 1;

  function inner() {
    var b = 2;
  }

  inner();
}

outer();
30.1. Does the inner function have access to the outer function scope?

your answer here

30.2. Does the outer function have access to the inner function scope?

your answer here

Section: Challenges


1.1 Create a function calculateAreaOfACircle that receives radius as parameter. Use a constant PI equal to 3.14159. Avoid the temptation of using the Mathlibrary.

Solution:

// create the constat PI here


// create your function here


// Do NOT touch this code.
console.log('Expect area of a circle with radius = "3" to be "28.27431" ->', calculateAreaOfACircle(3) == 28.27431)