Skip to main content

React assessment on Linkedin

Linkedin offers an online quiz to test React.js skills. I collected questions from this test.

1) When do you use useLayoutEffect?

( ) to change the layout of the screen
( ) when you need the browser to paint before the effect runs
(*) to complete the update
( ) to optimize for all devices

2) How do you fix the syntax error that results from running the code?

const person = (firstName, lastName) => 
{
first: firstName,
last: lastName
console.log(person("Jill", "Wilson"));
( ) Add a return statement before the first curly brace
(*) Wrap the object in parentheses
( ) Call the function from another file
( ) Replace the object with an array

3) What is the children prop?

( ) a property that lets you pass data to child elements
(*) a property that lets you pass components as data to other components
( ) a property that lets you set an array as a property
( ) a property that adds child components to state

4) What is [e.target.id] called in the following code snippet?

handleChange(e) {
this.setState({[e.target.id]: e.target.value})
}
( ) a set value
(*) a computed property name
( ) a dynamic key
( ) a JSX code string

5) What is the name of the tool used to take JSX and turn it into createElement calls?

( ) JSX Editor
( ) Browser Buddy
(*) Babel
( ) ReactDOM

6) Why is it a good idea to pass a function to setStateinstead of an object?

( ) It makes sure that the object is not mutated
( ) It is more functional than an object
(*) setState is asynchronous and might result in out of sync values.
( ) It automatically updates a component

7) When using webpack, why would you need to use a loader?

( ) to put together physical file folders
( ) to load external data
( ) to load the website into everyone's phone
(*) to process files

8) Which of these terms commonly describes React applications?

( ) closed
( ) integrated
(*) declarative
( ) imperative

9) All React components must act like ____ with respect to their props.

(*) pure functions
( ) higher-order functions
( ) recursive functions
( ) monads

10) What do you call the message wrapped in curly braces below?

const message = "Hi there";
const element = <p>{message}</p>
(*) a JSX wrapper
( ) a JS function
( ) a JS expression
( ) a JS element

11) What can you use to handle code-splitting?

( ) React.split
( ) React.fallback
( ) React.memo
(*) React.lazy

12) Which of these Hooks could be used to update a documents title?

( ) useEffect(function() {title = name + ' ' + lastname;})
( ) useEffect(() => {title = name + ' ' + lastname;})
(*) useEffect(function updateTitle() {document.title = name + ' ' + lastname;})
( ) useEffect(function updateTitle() {name + ' ' + lastname;})

13) Which attribute do you use to replace innerHTML in the browser DOM?

(*) dangerouslySetInnerHTML
( ) strangeHTML
( ) weirdSetInnerHTML
( ) injectHTML

14) What property do you need to add to the Susense component in order to display a spinner or loading state?

function MyComponent() {
return (
<Suspense>
                 <div><Message/></div>
</Suspense>
        );
}
( ) spinner
(?) fallback
( ) loading
( ) lazy

15) React components are composed to create a user interface. How are components composed?

( ) with webpack
( ) with code splitting
(*) by nesting components
( ) by putting them in the same file

Comments

Popular posts from this blog

An interview exercise #1

An exercise from Amadeus interview /* Input: number 2543 Output: index of the digit that is needed to remove to get the maximum number from the original number [0]2: 543 -> It is a maximum, so answer is 0 [1]5: 243 [2]4: 253 [3]3: 254 */ function findIndexToGetMax (n) { if (n < 10 ) return null ; let digits = n. toString (). split ( '' ). map (d => parseInt (d)); let current_n = digits[ 0 ]; let pos_n = 0 ; for ( let i = 1 ; i < digits.length; i++) { if (current_n < digits[i]) { return pos_n; } else { current_n = digits[i]; pos_n = i; } } return pos_n; } let tests = { 2526 : 0 , 9526 : 2 , 19 : 0 , 10 : 1 , 12345 : 0 , 54321 : 4 } ; let expected_n; let testedValue_n; for ( let key_s in tests) { if (!tests. hasOwnProperty (key_s)) continue ; expected_n = tests[key_s]; testedValue_n = findIndexToGetMax ( parseInt (key_s)); if (testedValue_n != expected_n) { console. log ( ...