CSCE 102 Exam 2 Questions and
Answers 100% Pass
How do you create a new object in JavaScript?
By using the `new` keyword with a constructor function, e.g., `let obj = new Object();`.
What is the purpose of the `map()` method in JavaScript arrays?
To create a new array by applying a fun...
CSCE 102 Exam 2 Questions and
Answers 100% Pass
How do you create a new object in JavaScript?
✔✔ By using the `new` keyword with a constructor function, e.g., `let obj = new Object();`.
What is the purpose of the `map()` method in JavaScript arrays?
✔✔ To create a new array by applying a function to each element of the original array.
How do you check if a key exists in a Python dictionary?
✔✔ By using the `in` keyword, e.g., `key in dictionary`.
What does the `split()` method do in Python?
✔✔ It divides a string into a list of substrings based on a specified delimiter.
How do you perform string interpolation in JavaScript?
✔✔ By using template literals with backticks and `${}` for variables, e.g., `` `Hello, ${name}!`
``.
1
, What is the purpose of the `continue` statement in a loop?
✔✔ To skip the rest of the current iteration and proceed to the next iteration of the loop.
How do you create a new instance of a class in Python?
✔✔ By calling the class name as if it were a function, e.g., `instance = ClassName()`.
What is the role of the `filter()` method in JavaScript arrays?
✔✔ To create a new array containing only elements that pass a test provided by a function.
How do you remove the last item from a list in Python?
✔✔ By using the `pop()` method, e.g., `list.pop()`.
What is the purpose of the `self` keyword in Python classes?
✔✔ To refer to the instance of the class within class methods.
What is the purpose of a `for` loop in programming?
✔✔ To repeatedly execute a block of code for a set number of iterations.
2
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ExcellentScores. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.99. You're not tied to anything after your purchase.