r/javaScriptStudyGroup • • Sep 13 '22

Simple Recursion Example in JavaScript

Thumbnail
youtube.com
5 Upvotes

r/javaScriptStudyGroup • • Aug 23 '22

Navbar With Tooltip On Hover Using HTML and CSS Only |

Thumbnail
youtu.be
5 Upvotes

r/javaScriptStudyGroup • • Aug 06 '22

Was asked this question in an interview. Looking for feedback as I couldn't solve it completely.

5 Upvotes

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 • • Jun 18 '22

Hi! Do you know any site where I can practice those problems that you can find during the interview process?

5 Upvotes

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 • • Apr 22 '22

Features Of React JS

Post image
5 Upvotes

r/javaScriptStudyGroup • • Apr 17 '22

Im having a test for my first job and i dont know how should i code this

Post image
5 Upvotes

r/javaScriptStudyGroup • • Mar 16 '22

I share my page. Full of games made by me in JavaScript. Criticisms are welcome. Thanks a lot.

Thumbnail
rubycave.com.ar
5 Upvotes

r/javaScriptStudyGroup • • Mar 15 '22

PHP vs ASP.NET: Head To Head Comparison

Post image
5 Upvotes

r/javaScriptStudyGroup • • Dec 27 '21

Basics of Programming Language. What is a Library, Framework, API, and Web Services?

Thumbnail
todaystechworld.com
5 Upvotes

r/javaScriptStudyGroup • • Oct 26 '21

JavaScript Interview Questions

Thumbnail
youtu.be
5 Upvotes

r/javaScriptStudyGroup • • Oct 02 '21

Infinite scroll | Pagination on API using JavaScript Generators

Thumbnail
blog.decipher.dev
5 Upvotes

r/javaScriptStudyGroup • • Aug 09 '21

Console.log() - The Right Way ✅

Thumbnail
ooshimus.com
5 Upvotes

r/javaScriptStudyGroup • • Aug 07 '21

jQuery ajax tutorials with example

Thumbnail
codetopology.com
5 Upvotes

r/javaScriptStudyGroup • • Jul 12 '21

Sidebar Menu HTML CSS | Without JavaScript

Thumbnail
youtu.be
5 Upvotes

r/javaScriptStudyGroup • • Jul 03 '21

Accordion Menu Using HTML And CSS Only | Pure HTML And CSS Only

Thumbnail
youtu.be
5 Upvotes

r/javaScriptStudyGroup • • May 04 '21

In-depth exploration of JavaScript iteration protocols

Thumbnail
nodejsdesignpatterns.com
5 Upvotes

r/javaScriptStudyGroup • • Apr 28 '21

Why Beginners NEED to Learn JavaScript

Thumbnail
youtu.be
5 Upvotes

r/javaScriptStudyGroup • • Mar 30 '21

5 Defining Characteristics of a Great Programmer

Thumbnail
medium.datadriveninvestor.com
5 Upvotes

r/javaScriptStudyGroup • • Jan 02 '21

Answering Tricky Java Script Interview Questions

Thumbnail
youtube.com
5 Upvotes

r/javaScriptStudyGroup • • Dec 30 '20

JavaScript Array Functions Cheat Sheet Part 3

Thumbnail
htmlspacecode.com
5 Upvotes

r/javaScriptStudyGroup • • Nov 29 '20

Eloquent JavaScript & JavaScript and JQuery books

5 Upvotes

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 • • Oct 11 '20

JavaScript map function with example

Thumbnail
codetopology.com
5 Upvotes

r/javaScriptStudyGroup • • Oct 07 '20

A Complete reference guide to Redux: State of the art state management

Thumbnail
soshace.com
5 Upvotes

r/javaScriptStudyGroup • • Sep 01 '20

15 Useful String Methods in JavaScript

Thumbnail
codetopology.com
5 Upvotes

r/javaScriptStudyGroup • • Aug 27 '20

The 4 differences between Observables and Promises in Javascript

Thumbnail vignesh.pro
5 Upvotes