Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
7 views

HTML, CSS and JS Boilerplate using Webpack, Babel, Sass and BrowserSync

I am working on a html, css and js boilerplate for my projects. My goal is to have a setup where I can fire off npm run watch and all files are watched and compiled....
0
votes
0answers
8 views

Combining arbitrary number of lists inside json

I have some JSON where each key stores an array, and I need to combine all those arrays into a single array. My current solution doesn't seem the most friendly to review, but without ...
3
votes
3answers
143 views

Cyclomatic Complexity reduction JS

I have a function that checks user level and limits the data before saving it to mongoDB database (pre 'save' middleware for mongoose). It have been getting complexity warnings and tried to rewrite it,...
0
votes
0answers
15 views

Split string into as few substrings as possible such that each substring is a palindrome

The task Given a string, split it into as few strings as possible such that each string is a palindrome. For example, given the input string racecarannakayak, return ["racecar", "anna", "...
2
votes
0answers
8 views

React onDrop function for a task manager

This a working function as part of a drag and drop task manager im playing around with. The function is working fine, but it just looks messy and long to me. I haven't added all the code as I'm ...
3
votes
2answers
38 views

Rotate a linked list to the right by k places

The task Given a linked list and a positive integer k, rotate the list to the right by k places. For example, given the linked list 7 -> 7 -> 3 -> 5 and k = 2, it should become 3 -> 5 -> 7 ...
-1
votes
0answers
21 views

Check if a web element has a specific property and apply changes to the DOM according to the property's existence

I wrote this Javascript snippet for a Polymer fronted, it works without issues. The only thing that it accomplishes is changing an icon's orientation whenever a user is clicking on any expandable-...
1
vote
0answers
25 views

Upload image without src attribute

We gave an option for user to Upload the image Image is uploading fine, but its not adding any img src tag for that uploaded image.... Is this is acceptable to upload image without using any img tag ?...
1
vote
1answer
77 views

A faster way to compute largest prime factor (Again, but a lot better)

I came up with this code after implementing the feedback given by @200_success. The previous one (A faster way to compute the largest prime factor) tested my patience, but still failed to give the ...
0
votes
0answers
17 views

Removing span elements without removing new list [on hold]

I am trying to making baby steps into javascript. I've got this exercise but I am struggling... I need to loose the span text of the id listHolder without changing the new list created. I thought i ...
1
vote
0answers
15 views

Transform vcards into contacts using functional programming in JavaScript

Context: I'm building a React app using Ramda as a helper library for functional programming. Users can import contacts into the app. These contacts can be vCards. I've written a function that: ...
3
votes
2answers
51 views

Function to format numbers with thousand separators and decimals

I've wroted this function because I was getting trouble using toLocaleString() in google-apps-script, and after some refactorings I got to a working code: ...
8
votes
4answers
2k views

A faster way to compute the largest prime factor

I am self-learning js and came across this problem(#3) from the Euler Project The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ...
3
votes
1answer
32 views

Grouping dates by weeks using reduce()

I am trying to implement a function groupWeeks(dates) using reduce that allows me to group an array of objects ...
2
votes
0answers
27 views

Node/Express authenticate Google email address

Trying to set up express server that will authenticate a user's Google email before proceeding. The code below works, but is there any way to make it more elegant? The whole ...
5
votes
1answer
72 views

Create a town administration report

I am Learning Javascript, after doing Java development for 2 years. I am doing a module on udemy which had a coding challenge which I completed and it works but wanted to get it reviewed to find out ...
0
votes
1answer
88 views

Suggestions for optimising this front end code

I've stumbled across some UI (React.js) code that I've worked out to have a time complexity of O(n^4) (I hope that's right, if not please do correct me). I was ...
-1
votes
0answers
24 views

Simple Javascript card game [on hold]

I'm currently learning JavaScript and I'm working on a small project but I need your help. I've been working on this card puller website were you can pull a card and it then adds the value of the ...
-1
votes
0answers
16 views

Modal pops up after ajax call completes instead of before [on hold]

I have a modal that I am using to tell the viewer "Please wait" while an AJAX call is made. It may be something as simple as how I am making the call. When I click my web link, it appears to be ...
1
vote
1answer
56 views

Sort Array By Parity

The task is taken from leetcode Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any ...
3
votes
3answers
72 views

httprequest to php login system

I'm trying to make a login system for my website which I'll be releasing in public later on. I have inserted some main samples of my code in here and I would like some useful advise or suggestions. ...
-3
votes
0answers
22 views

It manipulate the DOM [on hold]

Recently had given an online interview, in which interviewer asked this snippet and , told to find the error. The program compiles successfully however there was no error, not that i know of. Here the ...
1
vote
0answers
21 views

Wrapper for LeagueAPI in Node.js

Full code is here: https://github.com/LionelBergen/LeagueReddit I'm creating a wrapper for the LeagueAPI in Node.js. This includes methods to call various endpoints and classes to map the outputs &...
2
votes
2answers
43 views

N-Repeated Element in Size 2N Array

The task is taken from leetcode In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. Return the element repeated N times. ...
0
votes
1answer
23 views

Items also occurs in a set

The task You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how ...
1
vote
2answers
84 views

New Year Chaos JavaScript, needs to be sped up

Similar to this question but this is for Python Original problem with description on hacker rank I am currently trying to iterate through a large number of arrays and count how many times numbers ...
4
votes
3answers
380 views

Determine whether an integer is a palindrome

The task Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: ...
2
votes
0answers
53 views

Determine whether there exists a one-to-one character mapping from one string to another

The task Determine whether there exists a one-to-one character mapping from one string s1 to another s2. For example, given s1 = abc and s2 = bcd, return true since we can map a to b, b to ...
0
votes
1answer
34 views

Building complex sentences based on a data structure

I really do not like how bad this looks. It is not readable and I am not sure if I need the stacked map's. There are a lot of iterations going on here (map, join, replace) and performance is really ...
2
votes
3answers
70 views

Find non-duplicated integer in a list where every integer occurs three times except for one integer

The task Given an array of integers where every integer occurs three times except for one integer, which only occurs once, find and return the non-duplicated integer. For example, given [6,...
1
vote
0answers
32 views

Sliding marker on link hover and click with jQuery

The code I'm bringing forward is for a vertical menu, where I needed a marker to do the following: When hovering over a link the marker should slide down next to it. When not hovering over a link the ...
3
votes
1answer
79 views

Division without using division, multiplication, or modulus operators

The task Implement division of two positive integers without using the division, multiplication, or modulus operators. Return the quotient as an integer, ignoring the remainder. My solution <...
2
votes
2answers
41 views

Remove and Add items from array in nested javascript object

I have the following object at React state: ...
-3
votes
0answers
17 views

chart.js not rendering api data [closed]

Using Vue.js, Vue-chart.js and API fetch that returns an object with 2 arrays of chartData and chartLabels to pass to a line-chart. The chart does not render but in the image below chartData and ...
0
votes
0answers
22 views

Load content from files (and sometimes parse) in Sapper

I am making my first Sapper app and the pages are all in routes. I am now extracting the content into a separate directory and unsure if I'm doing anything right. Here is an excerpt from my directory ...
0
votes
1answer
36 views

Function that checks two objects with same fields and assigns old non-null values to new object if new values are empty or null

I have a function that checks two reference objects. They both have the same properties. The purpose of this method is to ensure that any non-null old values are not overwritten with null or empty ...
4
votes
1answer
39 views

Comparing 2 iOS and Android versions

Please review and let me know which version is better. I'm just trying to find any caveats or better ways to accomplish the a version comparison independent from Android and iOS. Formats accepted: '1....
2
votes
1answer
41 views

Using IndexedDB as an in-browser cache

In my site: Users have many Activities Each Activity has encoded_polyline data I display these encoded_polylines on a map I want to use IndexedDB (via Dexie) as an in-browser cache so that they don'...
1
vote
0answers
14 views

Google ChartWrapper bar formatted table

The end result is a bar formatted table chart that has expanding and minimising rows. The code below works fine but I'd like to know if there is a cleaner way to achieve the same result (see JSFiddle ...
1
vote
2answers
46 views

Sum of two numbers in array

The task You are given two non-empty arrays representing two non-negative integers. The digits are stored in reverse order and each of their items contain a single digit. Add the two numbers ...
1
vote
1answer
49 views

Find busiest period in building

The task You are given a list of data entries that represent entries and exits of groups of people into a building. An entry looks like this: {"timestamp": 1526579928, count: 3, "type": "...
3
votes
1answer
167 views

Tic tac toe game in a web browser

I have this tic tac toe game which is very old project of mine, though I made some changes on this to improve the script to perform better. This game is functional, Any logic improvements or other ...
0
votes
1answer
41 views

Find indices of two numbers such that they add up to a target

The task ...is taken from leetcode Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ...
0
votes
2answers
85 views

User interface HTML string generated using PHP

Goal This is very basic beginner script, only for prototyping, probably never to reach alpha/beta prototyping/production, is being designed/tested for performance. Its performance quality might be ...
1
vote
0answers
43 views

Find all pairs of unique indices in a list such that the concatenation of the two words is a palindrome

The task Given a list of words, find all pairs of unique indices such that the concatenation of the two words is a palindrome. For example, given the list ["code", "edoc", "da", "d"], return ...
1
vote
0answers
21 views

Salary-structure report using a web-presentation

I had to create a report which presents the salary structure of a firm. The data needed was provided by the client as CSV-files. I used PHP for the reading and preprocessing of the data. The actual ...
1
vote
1answer
48 views

Rotate a N by N matrix by 90 degrees clockwise

The task: Given an N by N matrix, rotate it by 90 degrees clockwise. For example, given the following matrix: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] you should return: [[7, 4, 1], [8, ...
1
vote
0answers
29 views

RxJS BehaviorSubject with asynchronous initial value

I am using RxJS to fetch a data structure from a server and cache it, but I also need to be able to overwrite the value locally (specifically, a user operation can change the server state, and the ...
1
vote
0answers
28 views

Node websockets

I have this code I use it for two things connect to lxd instances and emits any operation events it recieves over socket.io to the client Bridge between client and lxd for terminals Its pretty ...
1
vote
1answer
70 views

Given a list and a number k return whether any two numbers from the list add up to k

The task: Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. ...