How do you send json together with an image file in express? I understand you serve an image using res.sendFile But then what if you want to include json with the image? For example if you are serving a user’s profile data- name, info, etc and profile image. You can’t do and res.send(json). So how…
Tag: javascript
Get a value from a callback in another function NodeJS
I’m desperately trying to recover the value of a callback function but I have no idea how to do that. I have a function where I execute this code: Who performs this function: And which is called by this variable: I would like my `authentication’ variable to take the value returned in the callback,…
How do I match up text labels in a legend created in d3
I am building a data visualization project utilizing the d3 library. I have created a legend and am trying to match up text labels with that legend. To elaborate further, I have 10 rect objects created and colored per each line of my graph. I want text to appear adjacent to each rect object corresponding with…
Ties are still running win messages?
I’ve been messing around with a rock, paper scissors project that codecademy gets you to try, I’m pretty happy with it but I have one problem! When the result is a tie, it logs the tie message (perfect!) but also logs the win message linked with the result! How do I get it to ONLY log the tie mess…
In Javascript, how do I write one function that will effect multiple buttons, each with their own separate arrays?
I am currently setting up an application with three separate buttons, each which is supposed to randomly select an element from an array specific to that button. I’ve successfully coded it with individual functions for each button, but I was wondering if there is a way to condense it into a single funct…
happy number algo question solution not working
trying to figure out this coding problem: Write an algorithm to determine if a number n is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number e…
Pass the last parameter to function – JavaScript
If I have a function with two different parameters, how can I make it so that if I input only one parameter, it will use the input as the second parameter rather than the first parameter? For example, if I have this function: and call x(3), it will use the 3 for a and return “3, 2” I want it
V-chip not issuing input event to parent
I was hoping to resolve this on my own, but I am completely stuck. Any help is welcomed. Basically, this component prints a matrix 100×10 such as this: Threat1: AssetType1 AssetType2 AssetType3 AssetType4 […] Threat2: AssetType1 AssetType2 AssetType3 AssetType4 […] Threat3: AssetType1 AssetTy…
Javascript how to change font properties to script?
I found this script which is perfect for what I need. However I would like to change the font properties to make it bold and red for the result displayed. I looked all over and tried adding it but somehow I just seem to make it not function at all when I do. Any help is greatly appreciated. Here is
Web Audio API is not working properly, in google chrome browser
I’ve created a simple music player, which creates a bufferArray for a particular audio URL to play the music. It is working fine in many of my cellphone’s browser, so I guess there is no cross origin issue for audio URL. however chrome is not playing audio. Also I’ve created a Uint8Array for…