How do you reverse a string in JavaScript?
javascript
function reverseString(str) {
return str.split('').reverse().join('');
}This function splits the string into an array of characters, reverses the array, and joins it back into a string.
Write a SQL query to find the second highest salary.
sql SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
This query selects the maximum salary from the employees table that is less than the maximum salary overall.
What is the difference between synchronous and asynchronous code?
Synchronous code waits for each operation to complete before moving on, while asynchronous code allows other operations to run while waiting for a response.
Write a function to check if a string is a palindrome.
javascript
function isPalindrome(str) {
return str === str.split('').reverse().join('');
}This function checks if the string is the same forwards and backwards.