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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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
1answer
27 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
37 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....
-3
votes
0answers
15 views

chart.js not rendering api data [on hold]

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
17 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 ...
1
vote
0answers
28 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
1answer
273 views

Count number of islands 2d grid

This is a recursive approach using DFS to counting the number of islands. However, I would like to improve performance, while keeping the code clean concise and readable. Better yet can this be solved ...
2
votes
1answer
26 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'...
3
votes
1answer
52 views

Plain Page Flip Effect

I've created a very plain version of page flip onscroll. I made it to look like turning the pages of a book. It looks OK on browsers I have (Firefox 52.9, Chrome 49, IE8). Though the effect doesn't ...
1
vote
2answers
39 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
38 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": "...
1
vote
0answers
13 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 ...
0
votes
1answer
87 views

To Do List using basic JS

I learned javascript from some tutorials and as per advice, I thought of creating some task by my self. I wrote the following code and as I expected I saw the answer. If someone can assist me with how ...
4
votes
2answers
5k views

Check if string can be rearranged into a palindrome

I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
3
votes
1answer
156 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
40 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 ...
1
vote
3answers
63 views

Class constructor with async properties set from poke-api

So, this is for a clicker game I'm trying to build with Pokémon data drawn from the PokéAPI. Since I'm using Vue.js for the project, ...
0
votes
2answers
82 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
1answer
119 views

Unidirectional Bootstrap 3 carousel

I am working on a custom Bootstrap 3 carousel, with vertical, unidirectional, slide transitions. I want to prevent slide transitions from overlapping when the bullets are clicked in random order and ...
4
votes
1answer
323 views

JavaScript module to render and handle a form to add users

I recently switched to modular JavaScript and really like the idea of having the state of your application in JavaScript and not in the DOM. I want to know if what I am doing is considered best ...
2
votes
2answers
336 views

Web-App for to determine gender, age, emotions of a person (shown on an image)

I have made an app using Microsoft's Face API: Face API JavaScript Quick Start It shall analyze an image, showing a person's portrait, concerning the gender of the person, her/his age and emotions. ...
0
votes
1answer
80 views

Updating values in a database

I'm using standard jQuery Ajax to update values in the database and reflect the result in an output. This repetition seems like bad practice and I don't know enough about jQuery to consolidate this ...
2
votes
1answer
117 views

Modal displayed in Google Spreadsheet from Gscript

First: I'm not really a programmer. Thus, this application may be started in a bad way, but here is my question. It's not a specific one because I have no real clue about how to improve my code. Let ...
3
votes
1answer
542 views

Simple application for the game “Mad Lib”

It is an application for the game "Mad Lib". I decided to use bootstrap modal for the questions. Mad libs are a simple game where you create a story template with blanks for words. You, or another ...
2
votes
1answer
22 views

Rendering elements (which can change numbers) using jQuery

Currently when the user selects some tags in my app I generate them in a function, like this: ...
1
vote
0answers
20 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 ...
6
votes
1answer
40 views

Fetching movie data using jQuery

Requirements Display movie datas inside all tags that have the class movie_list Make an ajax call for fetching movie datas Fill loading text before fetch data If any error occurs during loading, the ...
5
votes
3answers
4k views

“Utopian Tree” challenge optimization

Problem statement The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the monsoon, when it doubles in height. The second growth cycle occurs during the ...
1
vote
1answer
91 views

User upload & Drag image and update text

I am allowing user to upload images & drag uploaded image once user click on mask images, also gave an option to Edit the text.... I am fetching mask images and text from json file.... I am ...
1
vote
0answers
33 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
1answer
44 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
26 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
33 views

View for logging telephone calls

As part of a web-based claims system I have created, there is a view for logging telephone calls. If a call is incoming, the claims handler asks the caller a series of data protection questions to ...
3
votes
1answer
75 views

AWS Lambda function to update newly added DynamoDB records

Approach All data is submitted into my DynamoDB from another Lambda > API Integration function whereas the lastUpdated row gets inserted as ...
4
votes
1answer
796 views

Turning a 2D array into a tree

I have the following data structure that's obtained from a third party: ...
9
votes
5answers
239 views

Sort a list of pairs representing an acyclic, partial automorphism

I have this sample data: let trips = [ { from: "DEN", to: "JFK" }, { from: "SEA", to: "DEN" }, { from: 'JFK', to: 'SEA' }, ]; ...
1
vote
1answer
41 views

Check whether string of brackets are well-formed

The task I asked similar questions here and here. Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed). For example, ...
1
vote
1answer
54 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. ...
2
votes
1answer
52 views

Player's scoring using JavaScript

Description: The questions are being showed in the console tap with player's score. It's questioning by prompt continually until the prompt input gets 'exit'. If the answer for each question is ...
3
votes
3answers
55 views

Implement integer exponentiation faster than repeated multiplication

The task: Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y. Do this faster than the naive method of repeated ...
2
votes
1answer
1k views

Node.js/Express middleware to relay requests to various APIs

I am creating a nodejs middleware server that will handle api transactions from a frontend and relay them to various api's (internal and external). The primary goal is to hide api keys from the ...
3
votes
2answers
29 views

Sliding marker on link hover with jQuery

The following code is for a vertical menu, where I needed a marker to slide down next to a link upon hovering over said link. Therefore I needed to change CSS properties of a HTML element (the top-...
4
votes
1answer
427 views

Find longest common string subsequence

The task (also found at https://www.youtube.com/watch?v=10WnvBk9sZc): Write a function that takes two strings, s1 and s2, and returns the longest common subsequence of s1 and s2. "ABAZDC", "...
2
votes
1answer
49 views

Flickity JS carousel plus nav slider

This is meant to present main content in the carousel above with a painless navigation below where the moment you start dragging the content keeps up. I was trying to avoid having to drag once per ...
4
votes
2answers
74 views

Check whether string of braces, brackets, and parentheses is balanced

The Task is taken from codewars: Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return true if ...
4
votes
1answer
420 views

Carousel in Vanilla JavaScript

I finally got my carousel to work in JavaScript, and I want to know what you guys think about it and what I can do better. ...
4
votes
2answers
3k views

Tic-Tac-Toe command line

I created a simple Tic-Tac-Toe. I'm looking for any critiques from a code standpoint: general structure / style / efficiency. Unfortunately I couldn't get a live demo working because of the ...
4
votes
1answer
98 views

Fetching data from API in JavaScript

I'm using Axios to fetch data from an API, and don't know if this is the best way to deal with APIs in ReactJS or not. I want to know if anyone can suggest edits or something to make the code more ...
1
vote
2answers
62 views

Minimum number of parentheses to be removed to make a string of parentheses balanced

The task: Given a string of parentheses, write a function to compute the minimum number of parentheses to be removed to make the string valid (i.e. each open parenthesis is eventually closed). ...
2
votes
1answer
56 views

Mongoose schema to store items from Wynncraft's API

I am making a Schema to store items from Wynncraft's API. See an example assortment of items here: https://api.wynncraft.com/public_api.php?action=itemDB&search=a I have not finished making the ...
12
votes
4answers
22k views

Count byte length of string

I am looking for some guidance and optimization pointers for my custom JavaScript function which counts the bytes in a string rather than just chars. The website uses UTF-8 and I am looking to ...