r/javaScriptStudyGroup • u/BMacDaddyJr • Sep 13 '22
r/javaScriptStudyGroup • u/ProgrammingTT • Aug 23 '22
Navbar With Tooltip On Hover Using HTML and CSS Only |
r/javaScriptStudyGroup • u/therealcopyninja • Aug 06 '22
Was asked this question in an interview. Looking for feedback as I couldn't solve it completely.
Create a task scheduler which accepts a list of task, schedules them based on dependencies
const tasks = [
{ "id": "a", "dependencies": [], action: function(){setTimeout(() => console.log("Executed a"),1000)} },
{ "id": "b", "dependencies": ["a", "c"], action: function(){setTimeout(() => console.log("Executed b"),1000)} },
{ "id": "c", "dependencies": ["a"], action: function(){setTimeout(() => console.log("Executed c"),1000)} },
{ "id": "d", "dependencies": ["e"], action: function(){setTimeout(() => console.log("Executed d"),1000)} },
{ "id": "e", "dependencies": ["b", "c"], action: function(){setTimeout(() => console.log("Executed e"),1000)} },
{ "id": "f", "dependencies": ["d"], action: function(){setTimeout(() => console.log("Executed f"),1000)} }
]
// Output:
// Executed a
// Executed c
// Executed b
// Executed e
// Executed d
// Executed f"
*/I was asked the above in an interview and I could not solve it in the limited time. Even now I do not how to solve it.
I cracked the dependency part during the call itself, and the output was as expected. But the interviewer expected the output to be shown in the same delay as mentioned in the setTimeouts. So each after 1 second.
Adding my attempt here so it could help anyone in need. I attempted the second part of the question many times later, but they would all get printed together always.
Any help is appreciated:
const schedule = async (tasks) => {
let nextTask = null;
const nextTaskIndex = tasks.findIndex(({ id, dependencies }) => {
return dependencies.length === 0;
});
if(nextTaskIndex === -1){
return;
}
nextTask = tasks[nextTaskIndex];
//Call
nextTask.action();
//Remove from tasks
tasks.splice(nextTaskIndex, 1);
const nextTaskId = nextTask.id;
tasks.forEach(({ id, dependencies }) => {
let foundIndex = dependencies.indexOf(nextTaskId);
if(foundIndex !== -1)
dependencies.splice(foundIndex, 1);
});
schedule(tasks);
};r/javaScriptStudyGroup • u/91Flavio91 • Jun 18 '22
Hi! Do you know any site where I can practice those problems that you can find during the interview process?
Hi everybody! Like I've just written in the title I was searching for a way to practice those coding problems that you could find in a junior interview. Do you know any site where there are this kind of problem-solving riddles?
Thank you!
r/javaScriptStudyGroup • u/Horror_Ice_7760 • Apr 17 '22
Im having a test for my first job and i dont know how should i code this
r/javaScriptStudyGroup • u/rulo1722 • Mar 16 '22
I share my page. Full of games made by me in JavaScript. Criticisms are welcome. Thanks a lot.
r/javaScriptStudyGroup • u/AnjuKamboz • Mar 15 '22
PHP vs ASP.NET: Head To Head Comparison
r/javaScriptStudyGroup • u/alok1141 • Dec 27 '21
Basics of Programming Language. What is a Library, Framework, API, and Web Services?
r/javaScriptStudyGroup • u/suresh9058 • Oct 26 '21
JavaScript Interview Questions
r/javaScriptStudyGroup • u/deepak_vi • Oct 02 '21
Infinite scroll | Pagination on API using JavaScript Generators
r/javaScriptStudyGroup • u/[deleted] • Aug 09 '21
Console.log() - The Right Way ✅
r/javaScriptStudyGroup • u/ct_author • Aug 07 '21
jQuery ajax tutorials with example
r/javaScriptStudyGroup • u/ProgrammingTT • Jul 12 '21
Sidebar Menu HTML CSS | Without JavaScript
r/javaScriptStudyGroup • u/ProgrammingTT • Jul 03 '21
Accordion Menu Using HTML And CSS Only | Pure HTML And CSS Only
r/javaScriptStudyGroup • u/loigiani • May 04 '21
In-depth exploration of JavaScript iteration protocols
r/javaScriptStudyGroup • u/SynthesizeMeSun • Apr 28 '21
Why Beginners NEED to Learn JavaScript
r/javaScriptStudyGroup • u/UncleBen2015 • Mar 30 '21
5 Defining Characteristics of a Great Programmer
r/javaScriptStudyGroup • u/[deleted] • Jan 02 '21
Answering Tricky Java Script Interview Questions
r/javaScriptStudyGroup • u/dcpushparaj • Dec 30 '20
JavaScript Array Functions Cheat Sheet Part 3
r/javaScriptStudyGroup • u/JamesBond-uk • Nov 29 '20
Eloquent JavaScript & JavaScript and JQuery books
JavaScript and JQuery by Jon Duckett and Eloquent JavaScript by Marijn Haverbeke are two of the best books for JavaScript but they are little dated considering JavaScript: The Definitive Guide has latest 2020 edition, does anyone know when will there be a updated edition for this books
r/javaScriptStudyGroup • u/ct_author • Oct 11 '20
JavaScript map function with example
r/javaScriptStudyGroup • u/UncleBen2015 • Oct 07 '20
A Complete reference guide to Redux: State of the art state management
r/javaScriptStudyGroup • u/ct_author • Sep 01 '20
15 Useful String Methods in JavaScript
r/javaScriptStudyGroup • u/shivenigma • Aug 27 '20