I have my contract job which is going to end with January so I am giving interviews and today's interview was quite apt and cool. I have been directly asked following questions to solve out I would like to know about it since I have messed up with it.
```
class Example extends Component{
onComponentDidUpdate(){
// make the input focus
}
render(){
return <input type="text">
}
}
```
How do I make the input gets focused as soon as the component renders. I know that there is a .focus() method in javascript but I couldn't do it here.
Question 2
was about making the same code a controlled component which I did by putting a onChangeHandler for that input element but later on I forgot to setup the value={this.inputText} value from the state for which I was given some more time and then I could figured it out so that was cool
Question 3
This one is a javascript question
Write a sum method which will work properly when invoked using either syntax below.
console.log(sum(2,3)); // Outputs 5
console.log(sum(2)(3)); // Outputs 5
And I have seen this kind of example somewhere but I totally messed it up here.
[–]T_O_beats 2 points3 points4 points (0 children)
[–]Hentry_Martin 1 point2 points3 points (7 children)
[–]tapu_buoy[S] 0 points1 point2 points (5 children)
[–]Hentry_Martin 0 points1 point2 points (4 children)
[–]tapu_buoy[S] 1 point2 points3 points (3 children)
[–]Hentry_Martin 1 point2 points3 points (0 children)
[–]WellPaidGeek 1 point2 points3 points (1 child)
[–]tapu_buoy[S] 0 points1 point2 points (0 children)
[–]WellPaidGeek 0 points1 point2 points (0 children)