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.

2
votes
2answers
34 views

Add one to the last array element

The task is taken from leetcode Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is ...
16
votes
3answers
2k views

Count all vowels in string

For a homework assignemnt, I was asked to complete this CodeStepByStep problem. It's coded correctly and gave me a right answer. I'm just wondering if there's an easier way to solve this problem ...
6
votes
1answer
505 views

JavaScript/Angular TicTacToe Minimax AI

I am interested in getting some feedback on the code for my TicTacToe game, implemented with AngularJS, particularly with respect to the AI logic, which is printed below. (The full code base is ...
3
votes
2answers
65 views
0
votes
1answer
78 views

Manipulating arrays to extract unique objects and count occurrences

The data describes cycling activities (key1) and chunks of them (key2). In total there are around 1,000 ...
2
votes
1answer
145 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 ...
5
votes
1answer
335 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 ...
1
vote
1answer
70 views

Find all starting indices in a string which are anagrams of a word

The task: Given a word W and a string S, find all starting indices in S which are anagrams of W. For example, given that W is "ab", and S is "abxaba", return 0, 3, and 4. My solution: ...
1
vote
2answers
62 views

First Unique Character in a String

The task is taken from leetcode Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return ...
3
votes
1answer
49 views

Building a unique array of db fields

This is stripped down from a project I'm working on: ...
6
votes
3answers
327 views

Class Activity Calculator

Introduction Class Activity Calculator is an online application to calculate the students' class activity grades. The class activity grade (CA) is calculated based on the marks a student gets during ...
2
votes
1answer
26 views

Alert about duplicates and remove them

So I want ask if I'm doing it right way. Im still learning.. I want check textarea duplicates and alert if duplicate and remove it. ...
1
vote
1answer
530 views

Is this jQuery Plugin for TreeView correct?

Looking for a review of my first published jQuery Plugin. It's for TreeViews, very basic example demo can be seen at: Demo Everything works fine, just looking to see if I can get some feedback on ...
6
votes
2answers
198 views

Tic-Tac-Toe code in JavaScript

I have developed a tic-tac-toe game in native JavaScript. Can you tell me how to optimize more and what are the missing things? JSBIN The logic, modular approach, testable and scalable? ...
3
votes
1answer
33 views

Addition of Strings

The task is taken from leetcode Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < ...
9
votes
2answers
6k views

A String.prototype.diff() implementation (text diff)

I just had the idea to develop an algorithm to calculate and highlight the difference between two strings. I know that there are already some libraries to do the job but I just tried to make my own. I ...
8
votes
1answer
407 views

SVG mosaic creator

Although my code works as expected, there are a few gotchas. A single row is not filled at once; instead, I can see partially filled rows during the rendering process(Fixed in the updated code below.)...
2
votes
2answers
46 views

Find All Numbers Disappeared in an Array

The task is taken from leetcode Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] ...
4
votes
2answers
461 views

JavaScript animation effect stack

I am building a library that uses animations in a canvas. I need to apply effects to some objects in the canvas and I came up with an effect stack that contains each effect to be executed on a ...
0
votes
1answer
19 views

Node.js DataBase class for adodb databases

A while ago I was working on a multipurpose database class (an es6 javascript class) that works with any database supporting adodb. This class is a wrapper on the "node-adodb" npm library. This ...
3
votes
1answer
228 views

Implementing Passport authentication with promises

Here is code implementing Passport authentication with a Google Strategy. It uses Mongoose to store and retrieve user data. You might need to be familiar with both of these technologies to review ...
0
votes
0answers
13 views

HTML5 Custom Audio Player with SASS

i made an audio player in html5 for learning purposes, also i tried to use BEM pattern with sass (i dont know if i did it well) i also encapsuled my code as much as possible, but i think i can make it ...
1
vote
1answer
22 views

Calculate function with optional operator argument

I am currently learning javascript at university. We have an assignment where we shall write various functions for calculating values. In one case, we shall write a function which returns the sum of ...
4
votes
1answer
124 views

Island Perimeter

The task is taken from leetcode You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically ...
3
votes
0answers
22 views

Simple Node.js user management system

I am working on a application that is made completely in JavaScript (other than the database) and I've created a simple user management system for the application. This user management system ...
-1
votes
0answers
25 views

How to count the number of occurrences of english word and chinese character in some files? [on hold]

How to count the number of occurrences of english word and chinese character in some files? I want to implement a function through Node.js: count the number of occurrences of english word and ...
2
votes
1answer
33 views

Find Median of Two Sorted Arrays in JS

The task is taken from leetcode There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should ...
-1
votes
0answers
18 views

Simple Coffee Ordering App [on hold]

This simple coffee ordering app will allow user to enter customer name and total cups of coffee. Any comment on coding style or in regards to data structure? ...
4
votes
0answers
18 views

Merging client names into orders using RxJS

I have an API which I can't modify. I have to use data as it is. I want to join data from two separate requests where the second request is based on data from the first one. I have a working ...
4
votes
2answers
69 views

Create a min stack

The task is taken from leetcode Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes ...
-1
votes
1answer
22 views

Fetch API - how to perform an action once data is retrieved, but before doing anything with the data? [on hold]

The code below retrieves data from database. Before the data is retrieved, a wait message is displayed. Once the data is retrieved, the message should be removed. What would be the best place to ...
4
votes
0answers
37 views

Given a string containing just parentheses, determine if the input string is valid

The task is taken from leetcode Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: ...
4
votes
2answers
81 views

Reverse Integer

The task is taken from leetcode Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: ...
-3
votes
0answers
22 views

How to search typed characters or word from json file using click function in javascript or jQuery [closed]

If i search any json data to given depends upon a keyword in search input filed i can't view any data in below json data. i attached example image for your reference. In this image showed one search ...
0
votes
0answers
10 views

Scroll to top and refresh page after user stopped scrolling? [closed]

I'm showcasing a web project in a museum setting. It's a project that relies heavy on scrolling, and needs to be reset between users. The page cannot simply best refreshed, it needs to be scrolled ...
1
vote
0answers
22 views

Applying option if property is true or not set at all [closed]

I have a case where I want to apply a format if a property is true or if it is not set at all. Here is what I have: ...
2
votes
1answer
50 views

Unique Email Addresses

The task was taken from leetcode Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, and leetcode....
1
vote
0answers
23 views

Add a folder with jstree

I read on SO and other pages that I should avoid JavascriptResult, I do not realy know why, but now I use JsonResult, because it is more common. Here is my Ajax in the cshtml: ...
6
votes
1answer
61 views

Jest unit test that handles a wrapped Promise

I've wrapped an imported function (a promise) and attempted to write unit tests that bring my codebase to 100% coverage. ...
-4
votes
0answers
20 views

I need to create a button Which will add another columns [closed]

I'm very new in JavaScript. How to create this table - I have a table with N rows and I need to add a column with function on click with JavaScript. But everything what I can do its create only 1 ...
5
votes
2answers
100 views

Flappy Bird game supporting local multiplayer of up to 2 players

The game is hosted here. GitHub repo This is my first Phaser 3 game/project and I'm still pretty new to Javascript so I'm sure there are many things I could be doing better. The number 1 thing that ...
0
votes
1answer
35 views

Retrieve a city list for a country and state

The code below is working properly but how do I make this code faster and more efficient. How do I perfect this code? Let's assume I have 1000 country, state and city records in a mongodb collection. ...
3
votes
3answers
40 views

Counting duration values

I have a durations as such: [{'duration': 3600}, {'duration': 3600}] And I want the output to be ...
5
votes
0answers
46 views

Container with most water

The task is taken from leetcode Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of ...
2
votes
3answers
8k views

Timer stop watch in AngularJS

I wrote a script for a timer. Is there any way to improve the code, with fewer number of lines? JSBIN ...
2
votes
1answer
34 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: ...
6
votes
1answer
54 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 ...
1
vote
0answers
37 views

multiple AJAX requests and multiple SetTimeout animations

multiple AJAX requests and multiple SetTimeout animations I wrote a piece of code that included multiple AJAX requests and multiple SetTimeout animations. I want the code to perform better, ...
1
vote
2answers
49 views

Longest Substring Without Repeating Characters in JS

The task is taken from leetcode Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: ...
2
votes
1answer
31 views

Searching for selectors not using document.querySelector/document.querySelectorAll

I had a technical interview the other day and failed a certain question: Given a CSS selector (can just be a class name, id or an arbitrary number of selectors), return the parent DOM ...