ECMAScript (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms and stand-alone interpreters / JIT engines. Use this tag for questions regarding ECMAScript 5 or 6 and its dialects / implementations: JavaScript, JScript, etc., excluding ...

learn more… | top users | synonyms

-3
votes
0answers
11 views

how i can Using functions from both the “drawingLibrary.js” and the “dateLibrary.js” and some methods of the Date object type [on hold]

to Draw a colored line. b. Create a Date object representing your date of birth and display it in the short form. (e.g. 12/10/1980) c. Display the month name of your birthday date. d. Draw a colored ...
0
votes
1answer
14 views

async.waterfall call

Does anyone have any recommendations for how I could make this async.waterfall call neater? Ideally I'd be able to do something like: ...
3
votes
0answers
9 views

Clean up duplicate string references and centralize properties/error handling

I don't like the idea of sprinkling process.env all over the place and wanted to abstract it out a bit. I'm new to Node and know there must be a better way to do a few things. Not repeat the name 4 ...
2
votes
1answer
23 views

Fitting multiple images in a given width

I was looking for a function which would take the overall width, max height, min height parameters as the input and fit multiple images in the given overall width adjusting their width. For an ...
0
votes
1answer
22 views

nodeJS, fs, path - creating new directorties

I wrote this function that takes 2 arguments - the path to an existing file - file, and the newRoot name. The function splits ...
0
votes
0answers
15 views

Express.js MVC controller router

So in the vein of an old dog trying to learn new tricks, I've decided to try to polish up my JavaScript skills. I've used it a lot but I don't claim expertise. I'm looking for any critique on the ...
0
votes
0answers
17 views

Implementation of dynamical forms for JSON ActiveRecord using JavaScript

I have some data in my database I store as JSON (PostgreSQL supports it). The data can be pretty flexible, something like work-experience, with names of previous companies and positions or education ...
-1
votes
0answers
12 views

Setting properties of an object on the basis of another tri-value property

I have an upvote/downvote function on a post with the following specs: Clicking on upvote/downvote will switch your upvote/downvote from the post. You cannot downvote your own post. You cannot remove ...
2
votes
1answer
43 views

Disable button when required inputs are not filled in

Currently I'm having a big form, with steps and a lot of complex fields. To make sure the user fills the required inputs and don't make them crazy pushing down the button submit when one required ...
3
votes
0answers
28 views

Designing a toy dependency injection library

Just for learning purpose I thought to write a simple and useful dependency injection service which would just do dependency injection but also it should expose its core too which would let the client ...
2
votes
2answers
169 views

Get character occurence count along with character in a string

I want to find character sequence count in a given string. Sample Input: aaaabbbbaaacccbbb Output: a4b4a3c3b3 My below function is working great and giving me the same result. but can this be ...
-5
votes
0answers
14 views

Javascript code only runs in Incognito Mode (Chrome) [on hold]

I've been working a project which attempts to visualize sorting algorithms. I just realized the JavaScript that I've written so far only runs in incognito mode. I've tried disabling all extensions and ...
4
votes
0answers
26 views

JQuery Double Timepicker

I'm pretty new on this platform and I want to improve my code skills by posting my javascript code. I'm sorry for my crappy english... I have one year of javascript/jQuery experience but I feel a bit ...
1
vote
1answer
32 views

Modelling an account manager in OOP

I have this task of modelling a system where given a group of users each can keep track of their expenses. The basic requirements are as followed: To be able to give credit to an user. Find all the ...
1
vote
1answer
35 views

Rotate every letter in string by K places

The challenge: Given a string S and a fixed number K, rotate every letter in S by K places (if reach the end of the alphabet, go back to the beginning). Letters should remain the same case. Symbols ...
0
votes
1answer
38 views

Maintaining state in a pagination handler

In my application I wrote a pagination code that retrieves data from the server as the user scrolls down. In this case, I need to mantain the current page, whether a request is being processed, and ...
0
votes
0answers
23 views

Writing promises

I'm learning promises (running in Node.js for now). Problems? Improvements? ...
0
votes
1answer
34 views

Simple implementation of the Observer pattern for AngularJS

I've been building AngularJS apps and have faced some issues with the promise pattern and in some situations the observer pattern seems to be a better approach. Therefore I've come up with the idea of ...
2
votes
0answers
20 views

Appending various elements to SVG

This is the code I currently have for adding various elements inside the svg and then inside a circle. On the text element I added 3 attributes that are the same. But I haven't found a way to remove ...
3
votes
0answers
39 views

Small JavaScript library for ECMAScript version detection

I wrote a library that detects the version of the ECMAScript that is running on JavaScript, and that also allows to check support for few syntax-features. For the ECMAScript version detection I run 4 ...
3
votes
0answers
40 views

finding substrings within arrays - javascript

I need to find the substrings within my array. If I have an array: ["abc", "abcd", "abcde", "xyz"], my method should return the array members: ...
3
votes
1answer
66 views

Return path to a value in a nested object

Description: Its not a programming challenge but I though to write a small utility which will return the path to a primitive value in a possibly nested object. The idea is not original. Code: ...
4
votes
1answer
31 views

Find the running median with 2 heaps

I wrote code to solve the running median challenge using 2 heaps, and I'd appreciate any and all feedback. Here is the problem: You have a list of numbers and are scanning them one by one. ...
3
votes
2answers
44 views

Locale language reducer

I am learning redux by doing a small project. Everything is working fine, but I need to know how I can refactor such code. For this situation, it might be good to use ...
2
votes
0answers
32 views

Padding with leading zeros or removing leading zeroes to make sure that array is at least given length

Please refrain from negative comments about the code being poor and inefficient and not idiomatic. I know that much, and that's why I'm here. I need a function, that takes a byte array and length and ...
-5
votes
0answers
21 views

How do I refine my code so that it is not so redundant? [duplicate]

I have this code that does not adhere to the OOP DRY principle. I've heard of slider functions that will slide images to left, I also need it to be multi functional for the four document id's that ...
-3
votes
1answer
60 views

Refactoring code to adhere to DRY principle [closed]

I'm relatively new to Javascript and jQuery. I have this code that has a ton of duplicated code and could use some refactoring. I've heard of Object Oriented Programming(OOP) and the Don't Repeat ...
-4
votes
0answers
21 views

Slideshow in vanilla javascript [closed]

I wrote this code of a slideshow in vanilla javascript and I need you help to improve it. It is working nice but I can see myself what there is a lor of repeating of the same code and I want to ...
-1
votes
2answers
55 views

Is there a more elegant way to catch a generic exception than using try-catch block?

Here are two sample blocks of my code: ...
4
votes
1answer
65 views

Form that reveals more fields as each step has been completed

I'm new to JavaScript and jQuery and need input about how to optimize my script: ...
1
vote
1answer
25 views

Attach / detach navigation bar depending on scrolled position of the document

The idea is the following: I have a large text with a header upon it and a navigation bar. The navigation bar is located between header and text. If the user scrolls downwards then the header-part ...
3
votes
1answer
77 views

The ListenHear Game - Listen and type the word

What it does: Speak a random word chosen from an array and ask the user to type the word in the box for 15 seconds If right, +1pts, reset the timer and go to next word. If wrong: do nothing. After ...
0
votes
0answers
12 views

AngularJs ui-router ui-sref not generating href from nested state with parameter [closed]

I'm new to angular (and an aspiring junior dev), and I can't get ui-router's ui-sref to generate an href. The code isn't pretty, but it works without ...
4
votes
1answer
92 views

ISO 8601 dates & times format into a more human readable format

I wrote from the ground up this small piece of code which transforms dates and times formatted in ISO 8601 format into a more human readable format, client-side. The main goal is that you can create ...
-2
votes
0answers
20 views

What is better rejected promise or throw an error when you perform a async request [closed]

Hey guys was discussing with my team this two approaches we wonder what would be the best for this function that performs a request. First example it will gracefully return a rejected promised. The ...
1
vote
0answers
31 views

Small camera app in react-native for Android

I'd like you to help me review a small camera app. Most of the code comes from here; I just changed it a little bit. I started dabbling with react-native for the first time. It seems kinda neat but I ...
-3
votes
0answers
16 views

Swap map bindings [closed]

I have an object similar to this: ...
-1
votes
1answer
36 views

Parsing HTML in Node.js with regex

I'm looking for an effective way to parse html content in node.JS. The objective is to extract data from inside the html, not handle objects. It is a server-side thing. I tried using jsdom and I ...
0
votes
0answers
24 views

Animate div positioning rearrangement [closed]

I am building a simple push-down effect which affects the position of two containers. So far I have managed to achieve a near-desired effect using fixed positioning for the hidden container, while ...
-4
votes
0answers
20 views

Merging of nested arrays based on key value [closed]

I have to merge 2 arrays with key value as follows: ...
4
votes
1answer
43 views

Getting the three next days

I'm simply getting the 3 future days from an array of objects based on the current day to display for a weather component. This is the first time I've attempted using ES6 and it's features so please ...
3
votes
3answers
157 views

Validate that brackets are balanced

I've done a test for a job (which I failed) and I'd like to know in which ways my code could've been better. Here are the questions and my answers, it's not very long. 1) Make a program that ...
1
vote
1answer
66 views

Add/remove class event handler

I wrote this if statement event listener to add and remove a class to a couple links based on changed.owl.carousel. However, I ...
4
votes
3answers
71 views

Showing animated company KPI stats

I am creating a web page in which I have 4 different numbers which show companies stats. I am using javascript to dynamically show these numbers from 0 to n (where 0 is the starting point of counter ...
3
votes
0answers
50 views

JavaScript Tic Tac Toe game challenge

I just completed the Tic Tac Toe challenge at freecodecamp. I am looking for input on how I could shorten the code. For the click events such as s1.onclick, I feel ...
1
vote
3answers
109 views

Playing with digits in JavaScript

I want to achieve this: digPow(89, 1) should return 1 since \$8^1 + 9^2 = 89 = 89 * 1\$ digPow(92, 1) should return -1 since ...
4
votes
2answers
63 views

JavaScript get total function

I have two JS functions that return a total number for me based on some properties. It works fine but feels a bit 'clunky'. Would there be a cleaner way of doing this? ...
1
vote
1answer
26 views

AnimationFrameController: requestAnimationFrame made easy

I am looking for feedback on what I can improve to a tool I have been using for several months now, my AnimationFrameController. I find requestAnimationFrame an ...