Professional Documents
Culture Documents
QUESTION-1:
import { useState } from 'react';
return (
<>
<span>{counter}</span>
<button onClick={() => {
setCounter(counter + 5);
setCounter(counter + 5);
alert(counter);
setCounter(counter + 5);
setCounter(counter + 5);
}}>Increment</button>
</>
)
}
QUESTION: 2
import { useState } from 'react';
return (
<>
<span>{counter}</span>
<button onClick={() => {
setCounter(counter => counter + 5);
setCounter(counter => counter + 5);
alert(counter);
setCounter(counter => counter + 5);
setCounter(counter => counter + 5);
}}>Increment</button>
</>
)
}
Router.js file
const http = require('http');
if (req.url == '/') {
res.end('This is HomePage');
}
else if (req.url == '/about') {
res.end('This is About Page');
}
else {
res.writeHead(404, { 'content-type': 'text/html' });
});
console.log(add(5,5))
console.log(sub(5,5))
console.log(mul(5,5))
operation.js file
const add = (a, b)=>{
return a + b;
}
module.exports = {
add,
sub,
mul
}
WORKING OF NODEJS:
Node.js is an entity that runs in a virtual environment, using JavaScript as the primary
scripting language. It uses a simple V8 environment to run on, which helps in the
provision of features like the non-blocking I/O and a single-threaded event loop.