|
There's a secret error somewhere in your secret code. You should fix that.
Seriously, how do you expect anyone here to help you fix your code, when you haven't shown us any of your code?
We can't see your screen. We can't access your computer. We can't read your mind. All we have to work with is what you type in the "message" box. If you can't explain the problem clearly, then we can't help you.
And adding "urgent" and "quick response" to your questions simply tells us that you can't manage your own time. It's not going to force us to answer your unanswerable question any quicker.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
A sign that I've appreciated in a couple of different supply rooms:
"A lack of planning on your part does not constitute an emergency on mine"
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Member 14732785 wrote: validate before dropping in the location if it already has an image, Simple. Write code for the drop event and to check if the img tag already has a src attribute.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
You should probably work on one DND interface first, and then create 2 more of them and DND each image to a specific DND box. Get the hang of DND first and how it works. It's not as easy as it sounds and DND has some events you have to listen for.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
function isAvgWhole(arr) {
return Number.isInteger(arr.reduce((accum, val) => accum + val) / arr.length)
}
function isAvgBowl(arr)
{
return Number.isInteger(arr.reduce(function(accum,val)
{
return (accum+val)/arr.length
}))
}
console.log(isAvgWhole([1,1,1,1]))
console.log(isAvgBowl([1,1,1,1]))
|
|
|
|
|
Because you're using two completely different calculations:
Method 1:
Sum up all of the items in the array. Divide the sum by the length of the array.
arr.reduce((accum, val) => accum + val) / arr.length
var accum = arr[0];
for (var i = 1; i < arr.length; i++) {
accum = accum + arr[i];
}
var result = accum / arr.length;
Method 2:
For each value in the array, add that value to the accumulator, and divide the intermediate result by the length of the array.
arr.reduce((accum, val) => (accum + val) / arr.length)
var accum = arr[0];
for (var i = 1; i < arr.length; i++) {
accum = accum + arr[i];
accum = accum / arr.length;
}
var result = accum;
Step through both methods with a debugger, or write out the steps on a piece of paper, and it should be obvious why the second method is wrong.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hey,
I am solving a problem on hackerrank(https://www.hackerrank.com/challenges/compare-the-triplets/problem?h_r=next-challenge&h_v=zen). The problem states to complete the function
compareTriplets which must return an array of two integers, the first being ALice's score and the secoond being Bob's.
compareTriplets has the following parameter(s):
a: an array of integers representing Alice's challenge rating
b: an array of integers representing Bob's challenge rating
For more detail on the problem, refer to the following link:
https://www.hackerrank.com/challenges/compare-the-triplets/problem?h_r=next-challenge&h_v=zen
For the same challenge i wrote the following solution:
function compareTriplets(a, b) {
for (let i = 0; i < 4; i ++) {
points=[];
pointsArray=[];
if (a[i] > b[i]) {
points[i]=1;
pointsArray.push(points[i])
}
if (a[i] === b[i]) {
points[i]=0;
}
if (b[i] > a[i]) {
points[i]=1;
pointsArray.push(points[i])
}
return pointsArray;
}
}
The problem states that the output should be like [1,1] i.e. [points earned by alice, points earned by bob]
But somehow it displays a array with four elements with the values [1], [], [1], []
Refer to https://ibb.co/GCkwM9j for further details.
Can anybody suggest anything?
|
|
|
|
|
Manish169 wrote: Can anybody suggest anything? I would suggest to begin by solving it by hand with a pen and a piece of paper, so that you have a clear knowledge of input and output data as well as required steps. As of now the code you showed does not pass the simplest logic checks: you are provided with triplets (3 values) but operate on array of four values; you have an inconditional return statement inside a loop, rendering this loop kind of useless (it will return at the first iteration); you create two data structures where you only need one; you do not add points to existing values but rather overwrite them.
So, do it by hand first; there is no chance for you to come up with a proper algorithm if you cannot solve it yourself with a pen and paper.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
I am looking for a method to close the current tab of the browser window using JavaScript.
|
|
|
|
|
Unfortunately you can't for security purposes. You can only close windows that were opened by Javascript.
|
|
|
|
|
|
Member 14713926 wrote: window.close(); If you know about this, why are you asking then?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Because it's an excuse to post a link to his spam "best programming tutorials" site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: "best programming tutorials" I could use some of that.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
In earlier times you got the full client path from a file upload and we were running ActiveX on our web pages. What's your point?
|
|
|
|
|
That is why websites were easily hacked in the earlier times due to inefficient security.
Like I said, javascript can only close windows that was opened by it.
|
|
|
|
|
Please see attached screenshot. I have question with two options. If user select option 1 then I would like to redirect to URL1 and if user select option 2 then I would like to redirect to URL2.
How can I do that?
JSON code is here. I am using HTML to show the question.
[
{
"question_code": "Q1",
"type": "radio",
"question": "Question1",
"required": "true",
"options": [
{
"code": "Q1OP1",
"text": "Option1",
"child": [ ],
"steps": 11
},
{
"text": "Option2",
"code": "Q1OP2",
"child": [ ],
}
}
]
|
|
|
|
|
|
Guys Please help me , How do I link this HTML with Css and Js properly?
https://codepen.io/gcarino/pen/LDgtn[^]
This is very short coding can someone please do this linking for me ?
I tried copying all codes in separate notepads and saved them as Css . Js and then I opened up HTML coding and linked my case and jss files and saved it .html but when I opened up website there's only blue box with " Learning J's " and a next button
And there are not any questions
Can someone please help me ??
|
|
|
|
|
I am making a live subway map, where I have divs representing trains, moving up and down the map.
I had no problem making them move, but I would like them to stop for a few seconds at each station.
Can someone tell me how I can include this in my code?
What line do I need to add, and where?
window.onload = () => {
startSetTimeoutAnimation();
};
function startSetTimeoutAnimation() {
const refreshRate = 1000 / 60;
const maxXPosition = 400;
let rect = document.getElementById('rect0');
let speedX = 0.01;
let positionX = 25;
window.setInterval(() => {
positionX = positionX + speedX;
if (positionX > maxXPosition || positionX < 25) {
speedX = speedX * (-1);
}
rect.style.top = positionX + 'px';
}, refreshRate);
}
|
|
|
|
|
images in are loading properly when I am running the application locally but even though images are appearing in the folder on Server but not being loaded in the Sources when I see them, in the same folder structure when ran locally they are being loaded - any help why would that happen? When even the folder contains the images - any help please - thank you.
|
|
|
|
|
You should know by now that we cannot guess what your code is doing. Please edit your question and show the proper details of the problem, including the code that is trying to load the images, and the actual path where they are stored.
|
|
|
|
|
Yeah I know but here is my problem.
Its an Ember Code and it will be converted into a big app.js file - before that all those files and everything would be converted - I am not sure how can I show you the code -Ember Code before conversion into js or after js conversion. I think Web-pack converts Ember files into js files - I am not very expert in it though. But anyways the Image files are showing up in the folder only thing is they aren't accessible in web page and they are not loading in the resource section when I checked using Chrome Developer tools, and similar scenario, when I use Chrome Dev Tools, Image files are loaded and showing-up in the resources section and it works locally though - any help please
|
|
|
|
|
As I already mentioned in the thread below I know nothing about Ember. And without some actual code that people will be able to read it will be impossible to even guess at a suggested course of action. The best I can offer is that you go to Ember.js - A framework for ambitious web developers[^] and try there.
|
|
|
|
|
Start by using the dev tools of your browser. Look at the network tab to see when the images are being loaded. Look at the url it is accessing and the response code. It might be they are missing, it might be security, might be looking in the wrong folder, might be looking on your local machine, could be the wrong http method, could be a case issues....it could be anything, we can't access your machine so can't tell you. You need to use the tools at your disposal to at least find out what the issue is, and once you know the underling problem you can work toward a solution.
|
|
|
|