21 Practical Development Coding Questions for Freshers
1. How do you reverse a string in JavaScript?
js
const str = 'hello';
const reversed = [Link]('').reverse().join('');
[Link](reversed); // 'olleh'
2. What is the difference between null and undefined?
js
let a;
[Link](a); // undefined
let b = null;
[Link](b); // null
3. How do you make an HTTP GET request in JavaScript?
js
fetch('[Link]
.then(res => [Link]())
.then(data => [Link](data));
4. How do you clone an object in JavaScript?
js
const original = { a: 1 };
const copy = { ...original };
[Link](copy); // { a: 1 }
5. How do you debounce a function in JavaScript?
js
function debounce(fn, delay) {
let timeout;
return function(...args) {
clearTimeout(timeout);
timeout = setTimeout(() => [Link](this, args), delay);
};
}
6. How to conditionally apply a class in React?
js
const isActive = true;
Page 1
21 Practical Development Coding Questions for Freshers
<div className={isActive ? 'active' : 'inactive'}>Hello</div>
7. How do you use useState in React?
js
const [count, setCount] = useState(0);
<button onClick={() => setCount(count + 1)}>Increment</button>
8. How to create a RESTful route in Express?
js
[Link]('/api/users', (req, res) => {
[Link]('Get all users');
});
9. How to connect MongoDB using Mongoose?
js
[Link]('mongodb://localhost/test')
.then(() => [Link]('Connected'))
.catch(err => [Link](err));
10. How do you return JSON from an Express API?
js
[Link]('/api', (req, res) => {
[Link]({ message: 'Hello World' });
});
11. What is destructuring in JavaScript?
js
const user = { name: 'Komolika', age: 22 };
const { name, age } = user;
[Link](name); // Komolika
12. What are arrow functions in JavaScript?
js
const add = (a, b) => a + b;
[Link](add(2, 3)); // 5
13. How do you sort an array of numbers?
js
const nums = [3, 1, 4];
Page 2
21 Practical Development Coding Questions for Freshers
[Link]((a, b) => a - b);
[Link](nums); // [1, 3, 4]
14. How to fetch data on component mount in React?
js
useEffect(() => {
fetch('/api/data')
.then(res => [Link]())
.then(setData);
}, []);
15. How to render a list in React?
js
const items = ['A', 'B'];
{[Link](item => <li key={item}>{item}</li>)}
16. How to create a responsive layout using Flexbox?
css
.container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
17. How to push code to GitHub?
sh
git add .
git commit -m "Initial commit"
git push origin main
18. How to use environment variables in [Link]?
js
require('dotenv').config();
[Link]([Link].DB_URI);
19. How to validate forms in HTML?
html
<input type="email" required />
Page 3
21 Practical Development Coding Questions for Freshers
20. How to use map() in JavaScript?
js
[1, 2, 3].map(n => n * 2); // [2, 4, 6]
21. What is the difference between map() and forEach()?
js
// map returns a new array
const doubled = [1, 2].map(x => x * 2);
// forEach doesn't return
[1, 2].forEach(x => [Link](x));
Page 4