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.

1
vote
0answers
11 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. ...
2
votes
0answers
14 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
22 views

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

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 ...
-1
votes
0answers
14 views

Simple Coffee Ordering App

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? ...
1
vote
1answer
24 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 ...
3
votes
0answers
11 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 ...
-1
votes
1answer
17 views

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

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
2answers
60 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 ...
4
votes
0answers
33 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: ...
0
votes
0answers
9 views

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

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 [on hold]

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: ...
1
vote
0answers
22 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: ...
2
votes
1answer
47 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....
-3
votes
0answers
17 views

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

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
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
45 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 ...
-4
votes
0answers
20 views

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

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 ...
4
votes
2answers
75 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: ...
1
vote
2answers
47 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
29 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 ...
-1
votes
0answers
21 views

code works fine any good suggestions to optimize and better code

The following code works fine. on clck ajax calls a method and return the query result. which i am displaying in view. the problem is i read many articles everyone is doing HTML code in controller ...
-2
votes
0answers
17 views

Output initial website content with PHP or JSON/JS [closed]

Right now I output my initial website content with PHP and when I want to update it I send a (jQuery) request, get JSON back and output it with JS. So I kind of have to do the same thing in several ...
1
vote
3answers
67 views

Add Two Numbers

The task is taken from leetcode You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single ...
2
votes
1answer
30 views

JavaScript Rock, Paper, Scissors

I have built a simple JS class with functional methods that create a Rock, Paper, Scissors game. I would be happy to get a non-opinionated review in terms of code being optimal. ...
1
vote
1answer
42 views

Find common characters (LeetCode)

The task is taken from leetcode Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). ...
6
votes
0answers
42 views

Todo list using pure JavaScript

I watched a YouTube video and completed the Todo List using Pure JavaScript. Below is the code I wrote. I want to improve this code, but it 's not clear how. I want to change this code to ...
-4
votes
0answers
24 views

Finding the number of numbers whose sum of digits is equal to this number [closed]

The task is to determine the number of M-digit positive integers whose sum of digits in odd digits is equal to N, where N[1;90], M[5;20]) I solve it this way: for example, M=5 => consider the ...
-4
votes
2answers
47 views

Highest and lowest number [closed]

Am trying to write a function that takes an array as a parameter, and then returns the highest and lowest number from the array without sorting the array. Below is my code, How can I make it better. ...
6
votes
3answers
262 views
+50

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
0answers
14 views

Apollo graphql authentication/ authorization [closed]

I am new in graphql and I am working on a project. My current goal is to integrate an auth/authorization system to protect all my resolvers. I found an example on Medium and I can not understand how a ...
-2
votes
0answers
26 views

document.getElementById and document.write [closed]

I need the variable N to be output to the text box 10 times. If I use document.write, then output 10 times, but not in the text field with id="solve". If same document.getElementById("solve").value ...
1
vote
1answer
38 views

Convert query string into object in JavaScript

Suppose I have this query and want to convert into an object a1.b2.article1=0&a2.article2=1&c3!article3=0&article16-abc=2 output for this should be ...
2
votes
1answer
25 views

Three.js Shortcuts

I've written shortcuts for the Three.js library. This is mainly for my personal use. I'm not that good with remembering the complex name of the Three.js library, so these shortcuts are meant to make ...
3
votes
1answer
72 views

Print a string of characters with their occurrences

I have worked out a solution for this problem, however I am trying to reach an O(1) solution without the use of two for loops. The output should read as a3b2c4d1 ...
11
votes
4answers
747 views

Cropping a message using array splits

I am trying to write a simple function to crop a given message to a specific length but at the same time not to cut the words in between and no trailing spaces in the end. Example: Input String: ...
2
votes
1answer
25 views

Tracking the stability of a website using ping monitor

I'm new to coding and made a small Node script that checks when a website is down because of high traffic. It's a website that sells tickets and I don't want to press F5 every 10 seconds to check if ...
2
votes
0answers
42 views

Separating items into ordered and unordered lists

I'm trying to group all the types which have ordered-list-item & unordered-list-item into new object. How can I simplify the function and reduce multiple return statements? ...
0
votes
0answers
20 views

Writing a unit test with Jest and Vue/test-utils, using a spy or calling a function directly?

I have a switch/case function that I'm testing and I have two versions of a unit test. I do not know which is the preferred method of writing a good test. component ...
1
vote
0answers
13 views

Enable/Disable Popper.js tooltip if element exists

I would like to disable the popper.js tooptip if there is an element with a specific class on the page. Let me explain ... I have a plugin that creates notifications dynamically, these notifications ...
6
votes
2answers
178 views
+50

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? ...
-2
votes
0answers
24 views

The code defines the number of M-digit natural numbers whose sum of digits in odd digits is equal to N. Using associative arrays [closed]

Enter n and m in the text field. Next, when you click on the "Решение" in the function PrintSolve() is determined by the number (variable kol) M-digit natural numbers, in which the sum of digits, ...
3
votes
4answers
104 views

Computing the BMI

The is my code to compute BMI (body mass index). How can I make this code better? ...
5
votes
1answer
46 views

15 Puzzle Game JavaScript

I have created a program that lets you play the fifteen puzzle game. You have to get the blocks into ascending order by moving them into the one open space. I would like some feedback on the code and ...
3
votes
1answer
54 views

Binary to Decimal Conversion App

I have created a binary to decimal calculator that needs to follow this spec: Arrays may not be used contain the binary digits entered by the user Determining the decimal equivalent of a particular ...
2
votes
1answer
40 views

Pascal's triangle JS formatting [closed]

For my code, up to the 5th row, the formatting of my triangle is fine. But once I hit the 6th row, the formatting turns funny because I start having double digits. Is there any way to fix this? Also ...
4
votes
2answers
83 views

Hackerrank.com - Sherlock and Anagrams

Summary: Given a string find the number of anagramic pairs of substrings of it. e.g 'abba' pairs are [a,a],[b,b],[ab,ba],[abb,bba] so we have 4 pairs. I'm wondering if anyone can help me improve my ...
4
votes
0answers
46 views

<select multiple> with dropdown

I wanted to use <select multiple> but was annoyed by the poor design on desktops which is why I created a version with dropdown: ...
3
votes
1answer
47 views

Twitter bot to post game of thrones memes

I created a twitter bot, that can parse a subreddit and post content from there to Twitter. I am running this bot using a cron-job, which starts the app using ...
3
votes
2answers
40 views

Robot Return to Origin

The task is taken from leetcode There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes ...