Course Resources

Search

Search IconIcon to open search

Last updated Unknown

# Midterm: JavaScript Technical Interview Practice

These questions are designed to help prepare you for the 305 Midterm. Once you feel familiar with the JavaScript topics, try taking these without using notes for practice.

# Questions

Use loops rather than relying on built-in JS functions such as reverse() or filter() for the following questions. In a real interview this restriction may or may not apply, but it’s good practice!

# Return the reverse of the string passed to the function.
1
2
3
function reverseString(str) {
    // TODO
}
# Return the output of the calculation. Supported operators are +, -, *, / passed in as a string.
1
2
3
function calculate(num1, operator, num2) {
    // TODO
}
# Return the number of even numbers in the array
1
2
3
function countEvenNumbers(arr) {
	// TODO
}
# Return the index of the first occurrence of the element in the array
1
2
3
function findFirstIndex(arr, element) {
    // TODO
}
# Write a function that prints numbers from 1 to n.

For multiples of 3, print “Fizz” instead of the number. For multiples of 5, print “Buzz”. For numbers which are multiples of both 3 and 5, print “FizzBuzz”.

1
2
3
function fizzBuzz(n) {
	// TODO
}