0% found this document useful (0 votes)
99 views3 pages

Full-Stack Questions - Nonceblox

This summary provides high-level overviews of questions asked about frontend and backend development: 1) The frontend questions ask about the difference between two ways of updating state in React, the output order of asynchronous console logs, and whether two function declarations are equivalent. The backend questions ask about an error in nested database queries, the difference between insert and save methods, and how to handle retries with promises and async/await. 2) Key frontend topics covered include React state, asynchronous behavior, and function declarations. Key backend topics covered include database queries, CRUD methods, and error handling. 3) Both frontend and backend questions focus on foundational concepts and best practices for asynchronous programming, data handling, and error

Uploaded by

name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views3 pages

Full-Stack Questions - Nonceblox

This summary provides high-level overviews of questions asked about frontend and backend development: 1) The frontend questions ask about the difference between two ways of updating state in React, the output order of asynchronous console logs, and whether two function declarations are equivalent. The backend questions ask about an error in nested database queries, the difference between insert and save methods, and how to handle retries with promises and async/await. 2) Key frontend topics covered include React state, asynchronous behavior, and function declarations. Key backend topics covered include database queries, CRUD methods, and error handling. 3) Both frontend and backend questions focus on foundational concepts and best practices for asynchronous programming, data handling, and error

Uploaded by

name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Frontend Questions

1. What is the difference between the below snippets?

- const [state, setState] = useState(0); setState(state + 1);


- const [state, setState] = useState(0); setState((state) => state + 1);

2. What would be the output of the below code? Support your answer with a reason.

console.log(1);

setTimeout(() => console.log(2), 1000);

setTimeout(() => console.log(3), 0);

console.log(4);

3. Are these functions the same? Support your answer with a reason.

function foo1() {

return {

bar: "hello"

};

function foo2() {

return

bar: "hello";

4. Write a custom hook for toggling state [true → false & false → true].
Backend Questions
1. What is the error in the following code? Support your answer with a reason.
query(

"SELECT clientId FROM clients WHERE

clientName='picanteverde';",

function (id) {

query(

`SELECT * FROM transactions WHERE clientId=${id}`,

function (transactions) {

transactions.each((transac) => {

query(

`UPDATE transactions SET value = ${transac.value *

0.1} WHERE id=${

transac.id

}`,

(error) => {

if (!error) {

console.log("success!!");

} else {

console.log("error");

);

});

);

);

2. What is the difference between the following lines of code? Support your answer with a
reason.
db.cars.save({motor:"6-cylinder",color:"black"})

db.cars.insert(_id: “123”{motor:"6-cylinder",color:"black"})

3. Write this using try-catch


function wait(timeout) {

return new Promise((resolve) => {

setTimeout(() => {

resolve();

}, timeout);

});

async function requestWithRetry(url) {

const MAX_RETRIES = 10;

for (let i = 0; i <= MAX_RETRIES; i++) {

try {

return await request(url);

} catch (err) {

const timeout = Math.pow(2, i);

console.log("Waiting", timeout, "ms");

await wait(timeout);

console.log("Retrying", err.message, i);

}}

You might also like