In JavaScript, I have strings including newlines such as var s = “123n456” or var s = “123rn456”. Using console.log(s), the dev tools of a browser displays real newlines in …
Category: Questions
How can I loop through the array of objects and display on dropdown
I’m new to Javascript and I’d appreciate any help I can get. I’m currently working on a project and trying to loop over the select dropdown to display the lenses I have on my array but am encountering errors and i’m stuck. The page loads fine with the HTML content but the select option…
How to find matching keys in an object where each key’s value is an array of arrays?
I would like to find the most efficient way to search an object, where each value is an array of arrays. The search function would recieve an array [0,1,0], find all items that contain this array, and return an array of matching keys. for example [0,0,0] would return [“bob”,”joe”,̶…
Difference between two ways of resolving a promise
I would like to understand the difference between the two code snippets, both resolving promises in different ways but receiving the same result (resolving after a second). Which one is the right way? Answer In this case, where you’re not resolving with a value, there is no difference. In situations whe…
How do i push same object value in to an array
I’ve been trying to deal with the json below for a few days. If a certain value is duplicate, I want to add it to a new array. like this The groupBy function of lodash is the most similar, but I am not familiar with JavaScript. anyone can help me how to handling those json? Answer Below is another appro…
Open XML file in AppleScript with JavaScript syntax
I am writing my first bigger AppleScript and as I am usually developing TypeScript, I decided to use the JavaScript version of AppleScript. I need to read and parse an XML file. Apple has an Example for that on their documentation, however the documentation only has an example in the AppleScript syntax, not i…
how to save a variable with the current data saved in an interval updating state
I am builidng a typicall stopwatch/clock app in here. The issue: When clicking Pause Button then Split Button (which prints the elapsed time) and then start back, both the stopwatch and the printed time restart. That is because I am saving the Crono time in the handleClickSplit function. Any ideas on the best…
Cannot read properties of undefined (reading ‘classList’)
I’m following a tutorial for making BattleShip in javascript and html but i get an error : This is the tutorial: https://youtu.be/U64vIhh0TyM The error happens randomly sometimes, it’s been 5 days since this error occured and I can’t understand how to fix this. I hope that someone can find a…
how can i curve to progress bar in css
I would like to create a progress bar like this curve progress . But i don’t know how to make it. I created this one straight progress bar and here is my css code how can i curve to a progress bar ? is it possible or do i have to try an another tag? Answer My suggestion would be
Uncaught (in promise) SyntaxError: Unexpected end of JSON input error
This is simply add to cart function. Also means insert field to database. All is fine when it comes to adding to the database, however there is this error everytime I click add to cart(But still adds to database though). Here is my fetch code, leading to calling my controller. I’m not sure what json dat…