Hi everyone
I'm using Visual Studio Code and would like to use a variable from a JavaScript file in my html code.
This is easy enough to do until I try using Puppeteer in the JS file. If I add the following line to the JS code, I can no longer call my JS variable in the html file.
const...
let card_value = 0;
let count_of_a = 0;
let number_of_cards = Number(prompt("Enter the number of cards."));
if (number_of_cards >= 2 && number_of_cards <= 5) {
let cards = [];
for (let i = 0; i < number_of_cards; i++) {
cards[i] = prompt("Enter the value of card ");
}
var dict = {...
I Understand the basic theory behind spread operator.
const girlNames = ['Jessica', 'Emma', 'Amandine']
const newGirlNames = [...girlNames]
console.log(newGirlNames)
// Output: ["Jessica", "Emma", "Amandine"]
But I don't understand when it's applied. See here.
function createList() {...
<div class="body">
<div id="board">
<div id="bat" class="bat"></div>
<div id="ball" class="ball"></div>
</div>
</div>
This is my HTML.
I've done CSS For all of them and generated this:
Now, I want the bat to move left and right when I press arrow keys...
Here's the full code:
This is the code that I'm interested in:window.addEventListener("keydown", e => {
inputDir = { x: 0, y: 1 };
moveSound.play();
switch (e.key) {
case "ArrowUp":
inputDir.x = 0;
inputDir.y = -1;
break;
case "ArrowDown":
inputDir.x =...
https://www.physicsforums.com/threads/how-to-rewrite-callback-hell-using-promises-as-well-as-async-await.1048282/#post-6833326
My goal is to convert the callback hell in question to using promises.
The correct flow of program is:
Order created
Order received
Preparing food
Order ready
order...
Promises syntax that I learnt:
let p = new Promise(function (resolve, reject) {
let x = 20, y = 20;
if (x == y) {
resolve(); }
else {
reject();
}
})p.then(function () {
console.log("that's correct");
}) .catch(function () {
console.log("that's not correct");
})
I...
My webpage project has a button labeled 'Harmonics' with a mouse-click event. I want an image to be hidden as soon as the button is clicked, however this doesn't happen.
Here's a snippet of the html. It doesn't matter what order the two Javascript functions are called. The 'hidden' attribute...
I am creating a web page that will have several buttons on it. When a button is pressed it will play a tone or combination of tones.
With the Google Web Designer application, I can create a simple page with one button on it. I'm able to associate the clicking of that button with "Custom Code"...
Javascript Resistance Calculator
The values of the resistor are calculated from the colour of the bands. The values of the colours are shown in Table 1. The first band is the tens values. The second band gives the units, the third band is a multiplying factor the factor being 10band value. The...
Hello
A few weeks ago (March 7) I asked how to have Javascript read a data file of numbers into an array.
I now understand why this is such a challenge when running a code on a web page, locally.
I have since found a sufficient workaround. I hope I can share it in the hope that someone can...
Hello
I am aware that it is not natural for JavaScript to read a file; however I see it is being done. I am trying to read a local file of 100 numbers (separated by line breaks) into an array in JavaScript
(I am aware that there are better ways to do this, but this is going to be the way I...
Hello! (Wave)
I wanted to ask you if you are familiar with html, css, javascript and php... What is it about? 🤔
Here is for example an exercise:
Implement in HTML and CSS the site that is shown below (the specifications are marked with red). The site will be without functionality. How would...
Good Morning
I have understood, as a general rule and category (and I realize all such attempts to categorize are fraught with danger), the four generations
of languages, from as machine (first generation), to assembly (second generation), to compilable (third generation; e.g., C, FORTRAN) and...
Recently I want to make a image adder in html, which is just a app that add the rgb value of each pixel in simple bmp files together.It can be used to grayscales and other things.
I found this website that teches how to do that with the <canvas> element in html5...
I would like to add a email sending feature to my website, something like the the "CONTACT US" button here on PF.
When I was searching this topic online, I get various paragraphs from CodeProject and StackOverflow, I saw methods using mailto: and some other stuff, but none of those work on my...
Does anyone know of a good library in javascript that would help to develop technically accurate animations? I know there is stuff in python, but I'd like things to happen in the browser.
Apart from linear algebra with complex valued matrices and vectors, I'd like to have things like numerical...
Hi,
I would like to provide a tool for some calculation as a html table whose values the user may change and subsequently submit a JS script which uses these values as input. Do you know of some easy to use library to get the data from the table into JS?
Thank you,
DrDu
This is actually Java!
My current problem: I need my switch statement to show only the given information for each selected shape.
For example when I click "circle" on the drop down menu, I want my switch to ask for the radius only while showing my compute button and answer.
When I click...
After doing some research I came to the conclusion that JavaScript is the best language to learn for web design. However now I'm seeing that some browsers do not support it. I'm confused then on why it's the best web design language as opposed to HTML if there are compatibility issues.
Thanks...
Hi,
I am having problems integrating HTML, Javascript and PHP. I am using the instructions at this website to transfer data from PHP to Javascript:
http://www.dyn-web.com/tutorials/php-js/scalar.php
and have set up the following simple code to simply transfer a PHP array to Javascript but I...
hello i wanted to ask you that if we have a teacher website name.
when we open pdf of his website it opens in google drive.
when i opened c++ assignments file was zipping download is taking time but i am unable to download.
what is the correct procedure for downloading pdf of google drive
Hi,
I'm writing an HTML/Javascript application that will handle a large amount of data segregated into a set of n rings, each ring will have a set of m branches, and each branch will have four arrays of data, V, N, I, B. I would like to create a 3-D array to hold this data but am having...
Hi
I have a web page with a 400-line WebGL 3D-rendering javascript which also loads a 45K data file of vertices and other data. It also has a lot of math code. I notice it takes a while to load on slower machines (about 5-7 seconds) as a message on the lower left of the screen reports the %...
Recently I have been working on a gravity simulator using JavaScript and HTML Canvas
I know that is not the most practical method but it fits my current skill set at the moment
I have worked out the basics but due to my lack of experience in coding I was simply looking for people who better...
I have the following code creating an object on a web page:
My question is if the
function(event)
{
// var id=myid;
unbind(event, this);
}
part of the code below results in a unique instantiated function per anchor or will all anchors point to the...
I am creating the following combobox:
//stations store
var stationStore = Ext.create('Ext.data.Store', {
id: 'stationStore',
fields:[{name: 'station'}]
});
the store is build on app load, and is empty to start. At this point the combobox is hidden Once the user runs a search...
I thought that I would share some interesting visualizations that I have created from some personal driving data. I've recently been introduced to the wonderful world of the D3.js Javascript library. D3 stands for Data-Driven Documents is an extremely powerful and versatile data visualization...
This is going to be a long post. :wideeyed:
I have been teaching myself Javascript for a project that I'm working on and I am stuck on how to get inheritance working the way that I would like. If this was plain old Java, I would have been done days ago. Some background on the problem - I am...
I am a computer programmer, mostly in Windows, but a little bit into open source, Linux and Java. I work a lot in javascript and SQL of one kind or another, both of which are utilized somehow via all common platforms.
I am also interested in music, physics, and chemistry. I play piano and...
I recently finished a course of html and css at codeacademy.com and I think I learned a lot from that but I do not feel prepared to make websites that can, for example, load another page when a button is clicked.
Overall I want to know what type of languages are used to program sites like...
... the situation where you want a function to be defined after the DOM is ready, but don't want it to execute right when the DOM is ready (as happens if you simply put it in a document.ready(...) function)?
Any ideas much appreciated.
Repro steps:
Open this: http://jaminweb.com/projs/snakegame.php
Change the speed to Fast
Go get a couple pieces of food, lengthening your snake a few blocks
Notice how it's already moving slower
Code...
Either because I'm tired or because I'm stupid, I'm having trouble getting a method of my Snake Game to work correctly. This is the method that is supposed to reset the position of the snake's food.
this.moveFood = function()
{
var tx, ty...
I am learning Javascript and have made a multiplication table generating program.
But it's about 1000x slower than C#. Is there any problem with this code?
I used the same code as C#, just the syntax is different.
Here is the code:
<html>
<head lang="en">
<meta charset="UTF-8">...
I've been trying to use Google's YT JS API to build a dynamic web page that plays Youtube videos back-to-back, i.e. a personal playlist. Here's the documentation for the API: https://developers.google.com/youtube/js_api_reference
Right now I am struggling to get the first video to...
I figured out what the bug in my code is, but now I need to figure out how to best remedy it.
Here's my function:
function snake(C, C_h, C_w)
{
/* NOTE TO SELF: C is a Raphel object. Can't find a method to return the height
and...
Okay, so I have a function single_ops(w) that returns a JavaScript array of all strings that can be made from 1 operation on the string w:
function single_ops(w)
{
/* Given a word w, return an array of all strings that are w with:
(1) 1 letter inserted, that letter...
As you may have figured out, I'm obsessed with spending exorbitant amounts of time making optimizations to my code. Can anyone help me cut down on the number of comparisons in the following text2words function? The intent of the function should be easy to figure out from the comments...
Alright I'm trying to make a game using Java-Script, it is a 2-D side scroller
if ( xPositions[i]>this.x && xPositions[i]<this.x+50 && yPositions[i]>y && yPositions[i]<y+50) {
y-= 5;
fill(255, 255, 255, 127);
stroke(0, 0, 0, 127);
rect(80, 110, 280, 150, 15)...
I'm looking for recommendations for javascript courseware suitable for self-study. Most of what I've found assumes no programming experience and is too basic and not really usable for building skills to a professional level. I'm already proficient in OO languages such as C++ as well as being...
I should be able to figure this out myself, I know.
All it will display is text in html: It won't run any js. I am completely new to any sort of web programming and I've been searching the interwebs for hours. I'm using mongoose as my web server, and sublime 2 as my text editor...
So I made a little application to show the steps of approximating a squareroot using the Babylonian Method:
http://jaminweb.com/squarerootCalc.html
It's not working all the time.
When I do the squareroot of 25 starting with an initial guess of 3.1, it works:
Applying...
Mod note: The OP has found an answer to his question.
I am validating a text field in javascript in EXTJS 4 framework, based on the selected value of a text box:
else if (record.get("type") === "CELL_VALUE" && record.get("apply_before") === true)
{
Ext.Msg.alert("Field Validation"...
Does anyone know anything about JavaScript and/or HTML? I'm just really interested but I don't know where to start... If you are asking what for, then I want to learn to develop my own website or social network... (The social network doesn't have to be like Facebook, just for my own purposes...
Hi gang.
I am trying to test out how adding automatic rendering of Latex would possibly benefit MHB. This requires a few javascript functions from what I can gather so far, but I just don't have the experience with JS. If anyone feels like he or she might be able to help, please reply here or...
JavaScrypt is an encryption program [ 256AES ?] released in 2005 ...
http://www.fourmilab.ch/javascrypt/javascrypt.html
Is this still a secure method of encryption ? ,
an example of an encrypted messages is below, [ the key is a 64 character hexadecimal number ]
##### Encrypted...
Hello!
I am a newbie in javascript programming. I am trying to write a program where there will be 2 drop-down menu, one for month and another for days. There will be no content in the day 'select' tag at first but when a month will be selected from the month drop-down box, day drop-down will...
I am quite new to the JavaScript and HTML5 world, and I am having trouble with some code that I was hacking together (based on demo's from other people). I am trying to take a file as input (a binary image) and base64 encode it. I think I have the right function for the base64 encoding, I...