Questions tagged [javascript]

ECMAScript or ES (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms as stand-alone interpreters or JIT compilers. Use this tag for questions regarding all versions of ES up to the current ES8 and its dialects / implementations: JavaScript, JScript, etc., excluding ActionScript.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

Implement N worker queue using Promises in JavaScript

Write a code that will process a list of strings. Processing will be a Promise and it will be resolved in 1-10 seconds for example. Workers should take no more than limit strings and once one of the ...
0
votes
0answers
3 views

Using common code inside a Higher Order Component

I have a common List in mind which looks something like this: it has one remove button one input in which user can enter the name of element and on clicking insert the element will be added in ...
0
votes
0answers
6 views

DND print script in html5

i made a html script to quickly make a Dnd5 sheet, this was a project done over two weeks, i don't know what to say else then im learning js, css and html. i would love to learn how to make this ...
0
votes
0answers
20 views

Questions about class structure, inheritance, etc — Simple Rougelike in JS

I have built a small roguelike in JS using minimal frameworks (Tho I am using one library for things like FOV, map generation and a few other small things) This is my first 'real' project that was ...
0
votes
0answers
19 views

All combination of array in javascript [closed]

...
0
votes
1answer
43 views

How to refactoring function when I've to do many things in one function

I always want to improve my code by refactoring but when I've to work with complicated function that have many thing to do . How can I refactoring them. Here is my data for example I get data from ...
0
votes
1answer
40 views

Is there a way that I can write these if-else statements cleaner than I've written before? [closed]

so I wrote a code that has a lot of if-else statements and achieving what I need to accomplish but then I saw it was a complete mess and I want it to rewrite in a much cleaner way but I don't know how ...
0
votes
1answer
35 views

Optimising String split into chunks of fixed size

I am looking to optimise my solution of the 'SMS problem', i.e splitting a String into chunks of the same size without splitting words. I did a recursion and am looking for ways to optimise that code,...
-1
votes
0answers
26 views

Tic Tac Toe - Javascript The Odin Project [closed]

I have been working on tic tac toe project as part of "The Odin Project" curriculum for the past three days. This was quite a challenge for me as I have attempted to do this project three times. If ...
3
votes
1answer
48 views

Swapping Nibbles

I have small (<250 bytes) chunk of binary data, where I know that almost always, the first nibble is going to be zero 0. For example, in hex: ...
2
votes
1answer
86 views

Split the restaurant bill

I'm trying to learn Javascript and I've set up a bill calculator. Most of the lines in the code are to deal with rounding. It has four main components: Allows you to enter the bill amount and tip ...
3
votes
1answer
82 views

Safe way of creating unique IDs

Is the code below safe to create unique ids for objects? I will create new yoga classes and need to have a unique id for each class. I made this small piece of code to generate the id numbers. ...
-1
votes
0answers
21 views

Page Coming Soon Subscribe for Notifications [closed]

I've just downloaded a script from PhpJabbers, which Uses Php & Javascript to Display a Page coming soon animated countdown. PhpJabbers - countdown Script: Coming-soon.html ...
0
votes
0answers
17 views

border each node in a network created using networkD3::forceNetwork() with a specific color [closed]

Consider the following network, can nodes be bordered with colors based on a column in the MisNodes data frame? The forceNetwork function has option to color edges but not node borders. I will ...
1
vote
0answers
60 views

HTML/CSS Gallery Website | Feedback on design and code

My goal was to create a portfolio site for my motion design work. The website should be modern and intuitive, yet pose a good gallery. Please also comment on the dark mode functionality and ...
0
votes
0answers
17 views

Uploading an image, getting its Sha-256, getting its EXIF, and saving all in separate NoSQL schemas using async functions

I'm working on a website with MEVN stack and this is my first big project. The way I have designed the schemas is like, that there's one "Super" schema, such as UserSchema or PostSchema, and then ...
1
vote
1answer
45 views

Better way to query and pass the elements to conditional operator in Javascript

I have the following function which has the required functionality. Is there any way that I can reduce the code but have the same functionality? ...
2
votes
2answers
75 views

JavaScript: Better way to sort an array by setting custom index

I'm trying to create a sorted array based on the below input data: Input: [{"title": "100_baz"}, {"title": "01_foo"}, {"title": "05_bar"}] ...
2
votes
1answer
33 views

Simple JS XMLHttp wrapper class

I was recently in a situation where I had to use vanilla js (no es6 and no http libraries, so I came up with this simple wrapper for get calls : ...
1
vote
1answer
39 views

Toggle CSS class on vote

I have this jQuery handled buttons. But I think I overdid it with the if else statements. I am wondering if the code can be more efficient in some way than what I ...
1
vote
1answer
43 views

More idiomatic way to move item from one dict value(list) to another?

Is there a more idiomatic way to handle the following scenario? I'm open to lodash, etc. if needed. This does what I want, but I feel that there is probably a ...
1
vote
1answer
34 views

Check browser compatibility for RequestAnimationFrame and Vanilla JavaScript .animate() API

I'm trying to set up some code to first test if the Vanilla JavaScript .animate() API is Supported, then if it's not check if ...
3
votes
1answer
62 views

Finding Common Items in arrays

My goal is to get a list of related statementIds in order of most repeated. In my database I have stems(Words): ...
3
votes
1answer
53 views

Most performant way to check if elements are overlapping [closed]

I know you can calculate if an element is overlapping another by comparing the top|bottom|right|left properties within the getBoundingClientRect method. However, you need to loop through the elements ...
0
votes
0answers
25 views

Rxjs - switchMap - countdown timer

I'm learning rxjs and I've implemented my own solution for task: "Countdown timer with pause and resume". Please, do a check review and give me some valueable feedback. Regards https://stackblitz....
-1
votes
0answers
34 views

Monthly Countdown Timer [closed]

I'm making Monthly Countdown for my project. It should be a countdown for every 1st day of the month. But I only found Yearly countdown and that is troubling me. Here is the example I got. Sorry for ...
2
votes
1answer
40 views

Graceful way to find combinations in JavaScript [closed]

I'm looking for combinations, not permutations, and have found some really great examples ranging from using flatMap such as https://stackoverflow.com/a/54329187/...
2
votes
1answer
44 views

Rewrite of Array.join

While rewriting Array so I can practice my javascript, I looked at my implementation of .join(). It seems a little clunky to me. ...
2
votes
1answer
56 views

Loading the stylesheets and scripts on my website

I have made a simple website and I have tried to reduce load times as much as possible. All the content that is loaded is necessary. Is there anything thing I can do to my code, such as structurally, ...
2
votes
0answers
33 views

Six Nations Prediction league Web App

I built a simple web app to manage my friends and I's six nation prediction league. This is my first go at web development so although it works I am guessing that I am not following all best practices ...
3
votes
1answer
111 views

Attempting a Strategy design pattern in JS

I'm going through the Head First Design Patterns book and I want to check whether I'm understanding some aspects of the first chapter. Does the code below program correctly to interfaces, encapsulate ...
5
votes
3answers
128 views

How can I Implement a better version of my function find the closest number to zero?

I recently had to do a test for a job interview, and the prompt was to code a function that returns the closest number to 0 given an array of negative and positive numbers. My function works ...
2
votes
0answers
40 views

Personal library application, allows user to add and remove books and update read status of an existing book

I have created my first crud javascript application to help me learn and I'm looking to hear from you any improvements or good practices I could apply to the code I've written. In my html I have a ...
3
votes
1answer
60 views

A todo application in React using hooks

I am learning React and wanted to implement a todo app using function components. Any suggestions and criticism is welcome, especially regarding best practices. ...
1
vote
0answers
34 views

Chatbot that lets users order coffee

Note: In order to keep this post somewhat short, I have moved some data from the database to the client-side. An example hereof is the prices object. This is a simple program/chatbot which users can ...
0
votes
0answers
36 views

Implementing Currying

I'm trying to learn functional programming (using Javascript), so I took a stab at implementing a curry function to properly grok it. Here's my code: Curry.js ...
-2
votes
1answer
42 views

Multiple semicolons when using ES2015 Arrow Function Syntax in Event Listener / Assignment Statements [closed]

TLDR: Does the javascript community regard it as poor syntax to include a terminating semicolon inside an anonymous function inside an Event Listener / Event Assignment statement, when the terminating ...
0
votes
0answers
17 views

Jquery tooltip with callback hover more tooltips displays delayed content

I have an html table with multiple rows and columns. ...
0
votes
1answer
38 views

JS, TS, handle 3 consecutive ifs / ternaries [closed]

I need to compare a title for 3 strings here what I'm doing ...
4
votes
0answers
45 views

JavaScript AVL Tree

I have been working through Introduction to Algorithms 3rd Edition, and have implemented an AVL tree through prototypal inheritance. The code presented here does work as expected based on the tests ...
2
votes
1answer
62 views

Comparing version numbers with JavaScript

I have written a function that compares two version number strings (e.g. 1.2.0 and 1.2.2) and return 1 if the first string is greater, ...
0
votes
1answer
38 views

Javacript/jQuery animation makes text appear/disappear as if typed

On Eric Amodio's website and the JS.ORG website, there is a Javascript animation which makes text appear/disappear as if it is being typed. I tried to replicate something similar but far more basic ...
4
votes
3answers
77 views

Gomoku board in JavaScript

EDIT: The result looks like this: http://gomokuu.glitch.me/ This is my code for gomoku. I made it with JavaScript and HTML. I think the checkWinner function can be ...
1
vote
1answer
38 views

correct coding structure in React.js?

I'm new to react and I'm still using the life cycle methods, so my question is since componentDidMount() acts like a constructor I'm planning to initialize ...
2
votes
0answers
65 views

Rust/WebAssembly VS pure JavaScript benchmark in Node.js

I've wanted to try Rust and WebAssembly for a while. I recently realized that I could try both at the same time by compiling Rust to WebAssembly. I wanted to know what the performances of something ...
0
votes
1answer
85 views

Asking for test: Calculator function javascript

I have made a code that can run a calculation from text. When I tested it, I didn't find any bugs. You are sharper than me. Maybe you can discover some bugs in this code. When you know some ...
2
votes
3answers
426 views

Sorting a list in ascending/descending order with a button toggle

I have this piece of code written as a function to handle a button-toggle for sorting a list in ascending and descending order. Below is the code which is working as expected, but I would appreciate ...
1
vote
0answers
21 views

knockout js refresh observable array from ajax [closed]

The following code refreshes an observable array of Run objects by calling an api method every 5 seconds. This code is working, but it seems like there's probably a utility method I'm missing that ...
2
votes
0answers
46 views

How to increase scalability the method that output each file while switching multiple many conditions? [closed]

I have a common style (common.scss) and a text direction (RTL, LTR) option file (option-document-direction-rtl.scss, ...
2
votes
0answers
34 views

Pokedex that displays flip cards

https://jsfiddle.net/0a7tcv2g/ I know I could locally store the data, write in es6, and all that, but I wanted to learn to work with APIs, and really understand JS through ES5, before brushing up my ...

1 2 3 4 5 169