piyush-eon / frontend-interview-questions Goto Github PK
View Code? Open in Web Editor NEWFrontend Interview Questions from My Youtube Videos
Home Page: https://www.youtube.com/roadsidecoder
Frontend Interview Questions from My Youtube Videos
Home Page: https://www.youtube.com/roadsidecoder
if (isMouseDown) {
const startBox = selectedBoxes[0];
const endBox = boxNumber;
const startRow = Math.floor((startBox - 1) / cols);
const startCol = (startBox - 1) % cols;
const endRow = Math.floor((endBox - 1) / cols);
const endCol = (endBox - 1) % cols;
const minRow = Math.min(startRow, endRow);
const maxRow = Math.max(startRow, endRow);
const minCol = Math.min(startCol, endCol);
const maxCol = Math.max(startCol, endCol);
const selected = []; // BUG
const selected = [startBox]; // FIX
for (let row = minRow; row <= maxRow; row++) {
for (let col = minCol; col <= maxCol; col++) {
selected.push(row * cols + col + 1);
}
}
console.log(selected);
setSelectedBoxes(selected);
}
There is a bug in the code, as we are loosing the initial coordinate of the selected part, when we are re-calculating it. It is avoided when we use the callBack hook because it is not calculated when selected box changes, as we have only given the parameter as mouseDown.
I thought of opening a PR, but i guess it's too minor of an issue, so i mentioned the fix in the issue itself.
Great tutorial!
kjwebewv
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.