Problem-solving in a different way | React Hook | Web accessibility

1. How to convert inch to feet

const inch = 50;

const inchToFeet = () => {

const feet = inch/12;

const fixedFeet = feet.toFixed(2)

return fixedFeet;

}

console.log(inchToFeet(), 'feet');

2. What is different between const and let variable type?

Const type variable will not reusable I mean we cannot set a new value.

Let type variable can set new value but not usable out of scope.

3. How to check LeapYear?

const checkYear = 2020;

if(checkYear % 4 === 0){

if(checkYear % 100){

if(checkYear % 400){

console.log(`${checkYear} is Leap year`);

}else{

console.log(`${checkYear} is not Leap year`);

}

}else{

console.log(`${checkYear} is not Leap year`);

}

}else{

console.log(`${checkYear} is not Leap year`);

}

4. How to get factorial in easy function?

const factorial = (num) => {

if(num < 0){

return -1;

}else if(num === 0){

return 1;

}else{

return (num * factorial(num — 1));

}

}

console.log(factorial(5));

5. How to get the Fibonacci series?

const getFibonacci = (fiboNum) => {

const fibonacci = (num) => {

if(num < 2) {

return num;

}

else {

return fibonacci(num-1) + fibonacci(num — 2);

}

}

for(let i = 0; i < fiboNum; i++) {

console.log(fibonacci(i));

}

}

getFibonacci(5);

6. How to swap 2 values without temp value?

let a = 2;

let b = 3;

a = b+a;

b = a — b;

a = a — b;

console.log(a, b);

7. How to remove Duplicate from the array list?

const list = [1, 2, 3, 3, 4, 4, 5]

const uniqueList = [];

list.map(item => {

if(uniqueList.indexOf(item) === -1){

uniqueList.push(item);

}

})

console.log(uniqueList);

8. How to get numbers of the word in a sentence?

const wordCount = (str) => {

const safeStr = str.trim();

const count = safeStr.split(“ “).length;

return count-1;

}

console.log(wordCount(‘ Test String ‘));

9. How to reverse Any String in an easy way?

function reverseString(str) {

return str.split(“”).reverse().join(“”);

}

console.log(reverseString(“hello world”));

10. How to join array in an easy method

const arr1 = [1, 2, 3];

const arr2 = [4, 5, 6];

const joinArray = […arr1, …arr2]

console.log(joinArray);

11. Why need to react Hook

React hook need for live update data and conditional update.

React Hook useState().

It's only worked for live data set and also updated data from anywhere.

useEffect();

useEffect render only when a condition will be changed.

12. What is accessibility and why need it?

Most of the big or medium websites need easy accessibility. We use accessibility for use web without keyboard or mouse or only reader and much more.

I’m Md Nimur Hasan, a MERN Stack Developer. I know MongoDB, express, react, node js, and continue deep learning on these.