Questions tagged [javascript]

JavaScript is primarily a language focused on web development. Being a monopoly on the front end and having Node on the back end. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.

Filter by
Sorted by
Tagged with
1
vote
1answer
31 views

Bottom-up merge sort

I think I programmed a bottom-up merge sort, but I'm a little sceptical that it will work under any data set. By now, I've tested it with many random arrays of massive lengths, and it seems to work; ...
1
vote
1answer
50 views

get address parts based on requested parts

I have different format of address in an array, those format looks like this ...
0
votes
0answers
38 views

Euler Project Problem #3 Optimization Needed

Well I was solving Problem 3 from Project Euler, but I just found out that my code is really bad, it would take so much time to finish processing the code and I honestly do not know how to optimize it....
0
votes
0answers
23 views

Improving multiple row creation query in JavaScript

I'm trying to create multiple rows in my db with an array. This array has multiple objects of products chosen by the client. ...
0
votes
0answers
31 views

Cookbook app in next.js

To start I'd like say that I'm a beginner writing my first Next.js app though I feel this question is more React related. I'm building an app where an user can add/edit stored food, recipes etc. which ...
1
vote
1answer
38 views

Euler Project Problem 2 JavaScript

Just solved Euler Project Problem 2 using JavaScript and I would like to know how I could improve my code. I do think it looks good, but you never know. Problem Statement Each new term in the ...
2
votes
2answers
23 views

group computed properties in vue component

I have the following vue component which all works fine ...
0
votes
1answer
43 views

Map chaining vs execute on first map

I have two large arrays of objects, which look something like: [ { key: "prop", Email: "someEmail@email.com" }, //... ] and ...
0
votes
0answers
19 views

Suggestions on how to upgrade HTML and CSS making a hamburger icon that transitions to "X" in the code below?

I'm interested in how I can improve my HTML and CSS? I didn't yet learn JS, even though I used it for onclick function, so I'm not currently interested in how to improve the JS in this code. I was ...
1
vote
0answers
29 views

avoid reassigning variables in javascript [closed]

I have the following piece of code. ...
8
votes
1answer
453 views

Check for balanced brackets in JavaScript

Rules: You should create a function that receives a string with brackets, parentheses, or curly brackets, an example: test('{A}') The function must check that the ...
-2
votes
0answers
70 views

Is there a way to write this better?

All 3 ids are basically the same button but different divs, but I had to rename them to accomplish what I was looking for. Is there a way to write this better? Any help is much appreciated. ...
1
vote
1answer
31 views

React - Component rendering weather data

Background: Hello, I'm a student (since 2 months) and I've created a small MVP of a weather application. So now I'm refactoring my code because it looks hideous and it is hard to work with. The ...
2
votes
2answers
57 views

Arithmetic progression using Recursion

take an array of two numbers who are not necessarily in order, and then add not just those numbers but any numbers in between. For example, [3,1] will be the same as 1+2+3 and not just 3+1. ...
6
votes
5answers
242 views

Extracting a part of a URL path

I have a string like the one below from which I am extracting the tariff name. ...
0
votes
2answers
68 views

Processing list of users- filtering out from refused list

The code below takes a list of users and displays two lists Refused users Admitted users Sample output: Refuse: Phil, Lola. Admit: Chris, Anne, Colin, Terri, Sam, Kay, Bruce. Any feedback is ...
2
votes
0answers
66 views

Create a collection of truly unique objects of custom type

I'm using TypeScript for my Vue app and have a custom type I'm working with ...
2
votes
2answers
62 views

Using JS Template Literals as for a simple Templating Engine

There are many template engines but my question is: Why do they still exist? Can we not achieve the same job with readily available JavaScript Template Literals? So influenced from this blogpost, I ...
1
vote
1answer
43 views

Protect Routes/Page with NextJS [closed]

I have a simple project that I built that protects the routes/pages of the website by using the if and else statement and putting each page with a function ...
2
votes
3answers
71 views

Recursive Filter/Search function

JSFiddle: https://jsfiddle.net/EddTally/jsa69f7r/3/#&togetherjs=zMFpAQcRTt Those who cannot access JSFiddle: ...
3
votes
0answers
38 views

How to remove a lot of the duplication in this JavaScript AST transformer?

I have put together this complete runnable source code with an example set of test expressions which it parses and prints. The code requires acorn, which is a JS ...
0
votes
0answers
33 views

jquery function updated from javascript

This is original Code ...
0
votes
0answers
18 views

Wordpress Custom Block that sources files from the theme images directory

The Goal Current PHP version 7.3.5 The block will have a function that sources a defined set of illustrations that are stored in {themeName}/images/illustrations. ...
2
votes
0answers
34 views

Undo/Redo implementation using Memento pattern Javascript

Relatively new to the Design patterns, Generally my works are writing function for the needs. But now i need to implement a undo redo functionality, so i just read about the different patterns which i ...
2
votes
2answers
56 views

JS Menu Post Get method

I have this JS ajax GET that returns menus to be used in a view. I wanted to see if there is any more way to write this method. Its a lot of code and just wanted to make sure there is no better way to ...
-2
votes
0answers
47 views

How to pass input data from ReactJS (Frontend) to Flask-Python (Backend)

I'm trying to build a directory website with ReactJS as a frontend and Python Flask as a backend. I'm trying to pass the text inputs in my searchbar.js to my Python script but I cant find a way to ...
2
votes
1answer
31 views

Intersection of 2D vector equation straight lines

I know the vectors that describe two lines, $$\mathbf{a} + \lambda\mathbf{d}$$ and $$\mathbf{b} + \mu\mathbf{d'}$$ I've written a JavaScript function to get the coordinates of the point of ...
0
votes
0answers
51 views

Refactoring the login form in React based on some rules [closed]

I am new to react, I tried to build login form and Code is as follows: LoginForm.js ...
3
votes
4answers
253 views

Convert number 1-5 from its spelt-out form

I'm working with an API that for some strange reason returns star ratings as words, like FIVE,FOUR,THREE,TWO,ONE. As far as I can see, there's no way to just get ...
0
votes
0answers
34 views

Implementing a programming language with objected-oriented programming in EcmaScript 6

I am trying to implement the Dis language as a webpage in order to reproduce Dis programs for code golfing easily on browser. Since a famous online environment tio.run is not accepting new languages, ...
0
votes
0answers
31 views

React filter-and-search algorithm

Currently working on a website with the following sorting function, but it's slow and reloads several times when I search for someone; how can I improve its performance? Or, more importantly, which ...
0
votes
0answers
22 views

Recreating WP Columns Block - Columns Container Only

I have been working on recreating the WP columns block using server-side rendered blocks. For the base creation of the block structure, I have used ...
4
votes
3answers
162 views

Random matchmaking for a p2p chat application

I'm a back-end developer (in PHP and Python) and I use JavaScript mostly for DOM manipulation. Now I'm writing a chat app in Node.js and I'm not sure if my code is the cleanest. Here is how it works: ...
2
votes
3answers
674 views

Zero Trim from array- JavaScript

The mission: Zero Trim Write a function which trims multiple zero's sequences to a single zero digit. The return value is the updated array. You are not allowed to use another array, and you need to ...
2
votes
2answers
63 views

Function to find substring in a list of strings and add them to the resulting list

I am trying to look for a substring in a list of strings. My end result is an array that contains the presence of substring first based on course.name and then ...
1
vote
0answers
37 views

Implement a single page application which fetches data via an endpoint and displays to a html page

I had to make a single-page application that fetches some figures via an endpoint, does some calculations, and displays them to an HTML page. Below is my ...
1
vote
2answers
85 views

Minimal Squares in a Rectangle

Minimal Squares in a Rectangle Given a rectangle of dimensions \$a\$ and \$b\$, we want to divide it into the minimal number of covering squares. The following rectangle has a dimensions of 5 x 3. It ...
3
votes
2answers
87 views

Tic Tac Toe in object oriented JavaScript

I've been working on a course assignment for 'The Odin Project' and was hoping to get a review of my code. As per the help guide, the code is fully functional. The criteria for this was pretty ...
3
votes
0answers
61 views

Cryptomarket data visualization

For a hobby project I want to visualize the current crypto market in bubbles. The idea is to clone cryptobubbles.net. I've already made a prototype at the moment, but the frames are on the low side. ...
3
votes
1answer
69 views

Average prime number from array- Javascript

My mission is to solve this: Write a function that will take an array of numbers, and will return the average of all numbers in the array that are prime number. So far I wrote this: ...
3
votes
1answer
226 views

Codility's biggest binary gap [100% score]

Task description A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 ...
1
vote
1answer
38 views

Finding the closest values in a sorted list that don't go under/over

For my project I have a sorted array of objects of timestamps (in milliseconds) and I need two functions. One function should find the closest time that doesn't go over a specific amount, and the ...
2
votes
3answers
101 views

Sort one array base on another array

The problem is as below: Two archery teams A and B compete with the same number of members. If the score of team A[i] is higher than that of team B[i], the total score of team A will be +1, so given ...
0
votes
1answer
48 views

Good approach to simple state management in vuejs for multiple instances [closed]

I am learning Vue.JS and I'm creating a simple todo app, where each list has a unique id. I am iterating through all of the list to create a Vue instance: ...
2
votes
2answers
94 views

Rock Paper Scissors Game using if statements

I am doing the codecademy course and had to do a rock paper scissors game as a project. Rather than following the instructions I tried Doing it on my own. How I could make the code more efficient? <...
2
votes
1answer
66 views

Is this a good solution to "Shortest Word" kata on codewars?

So the kata/problem was: "Simple, given a string of words, return the length of the shortest word(s)." Example test: findShort("Bitcoin will maybe save the world") And my solution ...
3
votes
1answer
50 views

Convert number from old range to new numeric range

I have a function that takes a specific number and a range, and re-scales it to the corresponding number in a different range. ...
1
vote
1answer
104 views

Check if a website is in a certain language and if so, block it

I try to block all websites in Hebrew because I want to give more time on websites in other languages. Given that many webmasters don't add ...
2
votes
3answers
86 views

Leetcode First Unique Character in a String code optimisation

I was working on First Unique Character in a String Question Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: ...
2
votes
1answer
39 views

iterating a big list of objects throws a memory issue

I'm writing a function which iterate through a list of objects and should return: true if all the items have the attributes (cp and type). false if all the items haven't the attributes (cp and type). ...

1
2 3 4 5
190