Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 340eb16

Browse files
Initial commit
0 parents commit 340eb16

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

‎README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# React-Coding-Round-Interview-Questions
2+
3+
[Edit on StackBlitz ⚡️](https://stackblitz.com/edit/stackblitz-starters-dfjd4q)

‎package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "stackblitz-starters-dfjd4q",
3+
"version": "0.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"react": "18.2.0",
7+
"react-dom": "18.2.0"
8+
},
9+
"scripts": {
10+
"start": "react-scripts start",
11+
"build": "react-scripts build",
12+
"test": "react-scripts test --env=jsdom",
13+
"eject": "react-scripts eject"
14+
},
15+
"devDependencies": {
16+
"react-scripts": "latest"
17+
}
18+
}

‎public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="root"></div>

‎src/App.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React, { useState } from 'react';
2+
import './style.css';
3+
4+
const numArr = [1, 2, 3];
5+
6+
const res = numArr.map((el) => el * 2);
7+
console.log(numArr, res); // [1, 2, 3] [2, 4, 6]
8+
9+
const res2 = numArr.forEach((el, i, arr) => (arr[i] = el * 2));
10+
console.log(numArr, res2); // [2, 4, 6] undefined
11+
12+
const obj = {
13+
name: 'Ram',
14+
age: 21,
15+
printInfo: function () {
16+
console.log(`My name is ${this.name}, and my age is ${this.age}`);
17+
},
18+
};
19+
20+
obj.printInfo(); // My name is Ram, and my age is 21
21+
22+
export default function App() {
23+
const ERROR_MSG = 'Age is must be greater than 18';
24+
const [text, setText] = useState('');
25+
const [isError, setError] = useState(false);
26+
const handleTextInput = (e) => {
27+
setError(false);
28+
console.log(e.target.value);
29+
setText(e.target.value);
30+
if (e.target.value < 18) {
31+
setError(true);
32+
}
33+
};
34+
return (
35+
<div>
36+
<input value={text} onChange={handleTextInput} />
37+
<br />
38+
{isError ? ERROR_MSG : null}
39+
</div>
40+
);
41+
}

‎src/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { StrictMode } from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
4+
import App from './App';
5+
6+
const rootElement = document.getElementById('root');
7+
const root = createRoot(rootElement);
8+
9+
root.render(
10+
<StrictMode>
11+
<App />
12+
</StrictMode>
13+
);

‎src/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
h1,
2+
p {
3+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
4+
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
5+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /