Skip to content

async/await in function synchronous – JavaScript

i have this code : Why am I getting the message that forEach is not defined? Answer You are getting an error forEach is not defined because there is no such function called forEach(). There is, though, a method Array.prototype.forEach():

How can I fill the inside of a SVG?

I am trying to fill a heart shape SVG on click using html, css and javascript, but it doesn’t seem to work. Here is the svg code : I have tried multiple solutions, such as using “fill” in CSS which only fills the stroke around the svg, but also removing everything in the path from the second…

Change multiple words in the string (JS)

JS function finds a word in the string and encodes it as “highlight”. But how can I change the multiple words to highlight instead of a single word? For example; Before: After: Answer My suggestion: You’ve edited your question, I’ll update my answer:

How to detect overlap in Phaser.js?

I am new to Phaserjs, and I am trying to make a shooting game. I want the damage function to fire when a bullet touches plane2, that is the green plane. Can somone please tell me what am I doing wrong here? Here is my code: Here is the link to the game if needed https://shoot.abaanshanid.repl.co/ Answer This …

Javascript: Duplicate each string value in an array

Tried googling for a while but couldn’t find my answer. I am trying to take a 3-character string and convert it to a 6-character string in which each of the 3 characters is duplicated. For example, 3ff would become 33ffff. First, I’m turning the string 3ff into the array [“3”, “f…

Fail to load .php files with ajax in Javascript

Instead of using jQuery here I am trying to use Javascript to load several .php files to display data from the database according to the user’s input. Below is an example of how my functions are like (and most of which are similar): and below is a screenshot of the index in the server. “sample.htm…

ApexCharts.exec updateSeries works only once

Have an issue that I’m trying to figure out with Apexcharts. just to lead with, I cant really post an example as the chart code is somewhat large and relies an web-sockets to get the data so I’m going to try my best to explain the flow with hopes somebody may know what I’m doing wrong here, …