CS 170 – Exam 2 Sample Questions Review

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/11

flashcard set

Earn XP

Description and Tags

This set of flashcards covers key concepts and coding practices discussed in CS 170 lecture notes, specifically focusing on algorithms, JavaScript syntax, and functions.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards

What is an algorithm in computer science?

A systematic method for producing a specified result.

2
New cards

What does a flowchart represent in programming?

A visual representation of the steps in a process or algorithm.

3
New cards

How to declare a variable correctly in JavaScript?

Remove illegal characters and ensure the variable starts with a letter or underscore.

4
New cards

What is the JavaScript syntax for checking if a variable 'age' is greater than 21?

if (age > 21) { alert('Access Granted!'); }

5
New cards

What will Math.round(2.73) return?

It will return 3.

6
New cards

What is the result of evaluating: (b == 15 && d > 15) || (c != 23) with b=3, d=15, c=23?

The result is false.

7
New cards

What is the formula to convert Kelvin to Fahrenheit in JavaScript?

F = K * 9/5 - 459.67.

8
New cards

How do you access the first element in an array declared as var cars = new Array(9);?

You can access it with cars[0].

9
New cards

What is the purpose of the function largeNums in JavaScript?

To return the count of numbers greater than 50 in an array.

10
New cards

What should be the order of execution for calculating and alerting shipping charges, sales tax, and total cost?

K O L N M J.

11
New cards

What error occurs when using a percentage in tax calculations like 8% in JavaScript?

It cannot be used as part of a calculation without defining it correctly.

12
New cards

How does the function findCharacter determine if a character is found in a string?

It checks each character in the string and returns 'Character found' if a match is found.