Podcast
Questions and Answers
What will the output be for the command console.log("3"+"4");
?
What will the output be for the command console.log("3"+"4");
?
What does the expression 3 + 4
in console.log(3 + 4);
evaluate to?
What does the expression 3 + 4
in console.log(3 + 4);
evaluate to?
Which output will result from executing both console.log("3"+"4");
and console.log(3+4);
?
Which output will result from executing both console.log("3"+"4");
and console.log(3+4);
?
If a variable sum
is initialized to 0 and a for loop is set to run from 1 to 10, what will sum
likely contain after the loop if it sums values continuously?
If a variable sum
is initialized to 0 and a for loop is set to run from 1 to 10, what will sum
likely contain after the loop if it sums values continuously?
Signup and view all the answers
Considering JavaScript's behavior, what type of output do you expect from console.log("3"+4);
?
Considering JavaScript's behavior, what type of output do you expect from console.log("3"+4);
?
Signup and view all the answers
Study Notes
Exam Questions for Fundamental Data Structures
-
Question 1: Data Types (5 pts): The code
console.log("3" + "4");
will output "34" to the console, because it performs string concatenation. The codeconsole.log(3 + 4);
will output 7, performing numerical addition. -
Question 2: Loops (5 pts): The code calculates the sum of numbers 1-7. For each iteration of the loop, the code adds the current value of
i
tosum
and prints the updated sum. The output displays the calculations in a readable format following the output format. -
Question 3: Functions and Loops (10 pts): A function is a block of reusable code. In JavaScript, a function is defined using the
function
keyword followed by the function name, parentheses containing parameters (optional), and curly braces containing the function body. This example gives a complete JavaScript code demonstrating the function for a given example. -
Question 4: Explanation and Modification (10 pts): The
greetUser
function prompts the user for their name and displays a personalized greeting. The example function can be modified to ask for additional user input such as age, and create more personal greetings. -
Question 5: HTML (10 pts): The answers to these questions would be the explanation of
what is this # x
in the HTML code (e.g., the<title>
tag sets the title of the HTML document,<p>
is a paragraph element). -
Question 6: CSS (5 pts): Specificity in CSS determines which style rule is applied to an element when there are multiple rules that match. This is determined by how specifically each selector targets the element.
-
Question 7: HTML Elements (5 pts): Semantical elements help to give an element a meaning in terms of the webpage (e.g.,
<article>
), while non-semantical elements exist without a precise page content meaning (e.g.,<div>
). -
Question 8: Identify Error in multTable (5 pts): One error in the example code is an incorrect redeclaration of the
matrix
variable inside the loop. Another example of an error are missing curly brackets, or issues within the loop structure (e.g., an incorrectpush
call for arow
element). -
Question 9: Console Output (3 pts): The JavaScript code will output information to the console, with specific output based on split functions, array indices, and string operations.
-
Question 10a: Implement Loop (3 pts): This question requires an explicit implementation of a loop for which its behaviour is specified in the prompt.
-
Question 10b: Complexity Analysis (3 pts): This question asks for the time complexity (Big O) of the implemented loop.
-
Question 11a: Max Function (3 pts): Create a function that returns the maximum value of two input arguments.
-
Question 11b: Console Output (3 pts): What output results from a given JavaScript code including a max function and array calculations.
-
Question 11c: Map-Reduce-Filter (5 pts): The function should split a string, filter elements of a specific length, transform elements to their length, and then return the maximum of the generated numbers.
-
Question 12a: Objects (5 pts): What output is produced from code using Course objects (including usage of the prettyPrint() method)?
-
Question 12b: Explanation of Objects (2 pts): Describe how the object Course is initiated using the constructor.
-
Question 13: Recursion (GCD) (6 pts): Implement the GCD algorithm using recursion.
-
Question 14: Draw Binary Tree (6 pts): Draw the binary tree based on the input data, node by node in terms of structure.
-
Question 15: Recursion on Trees (Counting Leaves) (6 pts): Implement a function that counts the number of leaf nodes in a given binary tree.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on fundamental data structures with this quiz covering data types, loops, and functions, specifically in JavaScript. Answer questions that challenge your understanding of coding principles and best practices. Perfect for students looking to solidify their programming skills!