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
2
votes
1answer
147 views

Fuzzy Humanize date using Moment.js for datatable searching

In my JS project, I am using datatable plugin to show data where I have a date column which users can filter/search. In order to help users to search using a logical string such as ...
2
votes
1answer
46 views

Simple React component to view cached data and test result from API

This is only the front end side of things which I have at the moment, as the back end is still being worked on. But as this is my first attempt at a react component, I'd like to know if there is ...
3
votes
1answer
131 views

Testing higher order reducer with jest

I'm trying to understand conception of creating unit tests for the frontend applications. I have created higher order reducer: ...
-1
votes
0answers
9 views

Usage of JS object in HTML, while attempting to loop HTML

The CSS is unnecessary, as my primary focus is the interaction between the HTML, JS, and external resources. I've implemented a carousel that would be edited to consume well over 100 lines, so I ...
4
votes
2answers
108 views

Zig-zag child element with Flexbox and JavaScript

Recently I found a question on StackOverflow that seemed very interesting: How to make HTML elements "zig zag" this way: ...
4
votes
1answer
44 views

Disabling a form button while there's an http request running

I have a form built with react, formik and yup, and this form has some async validations. Apparently, some users were able to bypass these validations, and to prevent some errors, I wanted to disable ...
-3
votes
0answers
18 views

Skybox for WebGl [closed]

I am new here. So I was self-learning on WebGL for my individual assignment and me still new to this computer graphic things. I want to add Skybox in my animation system but I failed to do it after a ...
3
votes
2answers
164 views

Blogging application with Codeigniter back-end and AngularJS front-end

I am working on a blog application with Codeigniter 3.1.8 and AngularJS v1.7.8. The Dashboard of the application is "pure" Codeigniter, with Models, Controllers, and views, while the fronted is made ...
6
votes
1answer
108 views

Recursive component JSON configuration builder

My goal here is to make data driven nested forms in React. I've created a function that points to a form configuration JSON, which can contain both components and references to other configuration ...
3
votes
1answer
58 views

Basic input system for a few form fields

I am attempting to port a linear function that I designed in a spreadsheet into HTML and Javascript. It's based on linear least squares where I have to take a Matrix and multiply it by its ...
1
vote
0answers
19 views

Redux Reselect Selector [closed]

I've got this really convoluted reselect selector. It's going a few levels deep and setting a couple of attributes. What's a good way to split this up to make it more readable? Ideally in a "redux" ...
8
votes
1answer
312 views

Cat Clicker MVC

I'm training my coding and wish you guys to see how my code is. I made a cat clicker based on the MVC pattern. Basically it shows a list of cats and when you click a cat name it shows an image, and ...
7
votes
2answers
327 views

Prototype to add subtitle .srt support to any video element

I've written a JavaScript prototype which extends the video tag with a new function. ...
6
votes
4answers
1k views

Numerology Calculator

I've built the beginnings of a numerology calculator, and would like an experienced javascript developer to review this code. It works as expected, but I can't help but think there is a better way to ...
3
votes
0answers
17 views

Browser-editable SVG diagrams using JS & SVG.js

[This is my first question to Code Review and it might be a bit too much.] I want to give users the means to draw a simple diagram in the browser, and because it is partly a self-education project ...
5
votes
1answer
42 views

User-focused timeline logging

I'm working on a small piece of my personal website. I'd like a timeline logging all of my relevant achievements in my career in Computer Science, in general. I'd like to implement a feature that ...
6
votes
1answer
31 views

Spread values to an object (Computed property names)

I would like to get a review of something, I have a function that creates an array of objects for a Drop-Down component (react-select). The function gets data, <...
-2
votes
0answers
47 views

Re-write JavaScript slider code but in Object Oriented Programming [closed]

I started Javascript 2 weeks ago but i just heard about OOP, i was already working on a project for fun, but now i wanna re write the same code but in OOP, i watched a lot of tutorials, i kinda ...
2
votes
1answer
151 views

Form validation function for React

I need to validate multiple input fields using React. I am using a simple if-else block for each input field but I would like to optimize my code and make it better. I feel there can be a better way ...
-2
votes
0answers
28 views
-2
votes
0answers
20 views

XML, .dtd help to make sure it is correct [closed]

I want to make sure that I am writing the code correctly and fully understand what is needed. My biggest concern is what tags to use, (? * | ect.) 2.The element feed 2.1.The element feed starts with ...
3
votes
1answer
69 views

Uploading a file from web-based platform to S3 bucket using NodeJS - Callback Hell

This code checks user permissions for uploading file, and if user can upload, then the file undergoes a check to see if it exists in SharePoint. If so then the file is pulled and uploaded to S3 bucket....
6
votes
3answers
86 views

Performance in particles.js library

Hey I'm trying to optimise particles.js library from Vincent Garrau in order to get 60fps @ 500 particles ~. I've already refactored the code to use a quad tree instead but it does not seem to be ...
2
votes
1answer
53 views

Leetcode: divide-two-integers

I was practicing divide-two-integers question from leetcode Question: Given two integers dividend and divisor, divide two integers without using multiplication, ...
4
votes
1answer
4k views

Simple RPG game

I decided to make a simple RPG game to practice JavaScript. I don't know a lot about JS best practices or things like that, so I rather have my code criticized now than build more code on top of bad ...
1
vote
1answer
51 views

Reduce the number of code if possible when creating a folder

My code below creates a folder based on the passed data from my client-side(VueJs) and checks if there's already an existing folder and deletes it if there is otherwise it will create a new one. My ...
0
votes
0answers
36 views

Javascript navigation [closed]

This code is for responsive navigation. When someone clicks on hamburger menu, it's run. I'm curious is this approach is good..? ...
3
votes
0answers
48 views

Creating a maze game where the game resets if you hit traps/walls and finishes when you hit a different color

Here’s my code, the traps are the slightly visible squares. The user controls a red square (with arrow keys) and cannot touch the walls or traps or else the game resets. Additionally, if the user ...
2
votes
0answers
105 views

How to apply best practices to javascript code

Hello I have recently started studying javascript, nodejs, and reactjs front end, and I have some questions about best practices to apply in this javascript world, I would like to ask for opinions ...
5
votes
2answers
58 views

Sparking animation for Button

I just came through a GitHub repo, which has an amazing animation for Button in Android. So, I thought why not make that for web buttons too. And I started ...
7
votes
2answers
1k views

Move all zeros to the left with TDD approach

The task Given an integer array, move all elements that are equal to 0 to the left while maintaining the order of other elements in the array. Let's look at the following integer array. ...
1
vote
1answer
66 views

Expand compressed string range

Say you have two strings: exp->aaccbb comp-> aa2bb This example will return true as there are 2 chars between aa and bb. I have written this code snippet and am wondering if there is a better way do ...
4
votes
0answers
45 views

Return probability (Javascript)

I've been working on a personal project. There's this game called TFT which is an autochess game. Each match is played by 8 players and there's a shared pool of champions, each champion have their ...
1
vote
1answer
112 views

Returning search results based off checkboxes

I use the following code to filter data from SQL and it works fine. However, below code is vulnerable to SQL injection, but all the ...
2
votes
0answers
40 views

Patterns used for accessing geolocation API

Here's how I'm using my location component: ...
5
votes
1answer
866 views

JavaScript quiz game

Here is the JavaScript code: ...
10
votes
1answer
203 views

Baseball player statistics controller

I'm somewhat new to JavaScript and AngularJS, and read in Doug Crockford's book that hoisted function declarations can lead to issues. If you have any pointers on how to structure my file, those would ...
4
votes
2answers
2k views

Reformatting a date from YYYY-MM-DD to MM/DD/YYYY

In this small bit of JavaScript, a date is passed in as YYYY-MM-DD. It's formatted like this to be passed to the backend system. On the front end, we need to ...
6
votes
1answer
101 views

NodeJs crawler for recipes

Here is my try on a crawler made in nodeJs with cheerio, I made it with the idea in mind to use it in a future project I wanna make. Here is the git link: https://github.com/Just4lol/CookCrawler If ...
0
votes
0answers
46 views

Repetitive code for an event listener

So I'm using the event emitter as some sort of an event bus(If I'm allowed to call it that). The problem I've stumbled upon is that my listeners might want different data than another listener. Since ...
2
votes
1answer
44 views

recursive function improvement

I am creating routes from an array of menuItems. I have written a recursive function, which works fine but I think the code can be improved. So, I need you guys to review my code and suggest me some ...
7
votes
2answers
591 views

Module with helper functions to initialize or reinitialize a Slick carousel

I been getting into javascript patterns and would love to get some feedback. I notice that I got some general helper functions. Is this a good approach of dealing with it? ...
10
votes
2answers
745 views

Javascript cron-to-human-readable translator

I'm developing a webpage displaying the scheduled pipelines from all projects of a GitLab instance. The scheduled time is expressed using CRON expressions, i.e. five digits as follows: Because not ...
1
vote
0answers
51 views

Tic-tac-toe vanilla js

I'm trying to improve my interview skills so I wrote one of the typical assignments - tic-tac-toe game. The main goals are: time limit: 30 minutes - 1h use only vanilla js I'll attach source but I ...
10
votes
2answers
120 views

Minesweeper Javascript (yes, another one)- JS Beginner, fully functional incl HTML and CSS

I created my first JavaScript program and I feel it's all over the place. I just started it without thinking too much about it. Now, I am quite sure I should have used OO style. Also, it seems there ...
4
votes
2answers
102 views

Alternative code to classes in Javascript?

I'm new to JavaScript and came across classes in ES6. Though they are great, I don't want to learn something that can be done in other ways. So, I created this code that does somehow similar job to ...
2
votes
1answer
77 views

Javascript map/filter/reduce over facebook messenger data

Context: I am making a website that allows people to upload their Facebook Messenger data, and see data visualizations for conversations. It is a React front-end, and a nodejs back-end. It doesn't ...
3
votes
0answers
14 views

React and D3 Alignment Histogram

I'm reasonably new to D3, and I've put together a class based React component which outputs a genomic alignment visually. The ...
4
votes
1answer
34 views

Adding users for login

I have some questions about best practices to apply in JavaScript. I would like to ask about my code and how I could improve. Starting with an example, I have 2 functions with different ways of ...