• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Any tips for debugging javascript?

I cant make it work and i dont know why :'(

It all makes sense in my head but it dosent work lol, any online debuggers or anything i can use?
 
Firefox javascript console. & Firebug
Safari/Chrome Error console......

IE9 might have something.. it released today didn't it..?
 
Excellent thanks, ive got firebug now.

If something is undefined is that a pretty specific error or is it one of these things that could basically be anything?
 
Excellent thanks, ive got firebug now.

If something is undefined is that a pretty specific error or is it one of these things that could basically be anything?

That message is pretty specific. Look into your includes and the order of your javascript for quick fixes.
 
How do i feed a functions output back into itself?

Ive got a function that takes an array as an input, the functions output is a modified array, is there any way i can feed that modified array back into the function again?

I tried setting up a while loop but that just fed the original array into the function 10 times and it spat out the same thing 10 times.
 
How do i feed a functions output back into itself?

Ive got a function that takes an array as an input, the functions output is a modified array, is there any way i can feed that modified array back into the function again?

I tried setting up a while loop but that just fed the original array into the function 10 times and it spat out the same thing 10 times.

Quickest way to get a response is to post your code.
 
How do i feed a functions output back into itself?

Ive got a function that takes an array as an input, the functions output is a modified array, is there any way i can feed that modified array back into the function again?

I tried setting up a while loop but that just fed the original array into the function 10 times and it spat out the same thing 10 times.

Haven't done it in Javascript, but you should be able to call a function from itself.

Code:
function dowork() {
  dowork();
}

Of course, you'll want to pass references, which I believe in Javascript is any object. Also, be sure to done some check before you go all recursive so you don't infinite loop.
 
Okay what ive got here:

function right(inputArray)

{

var outputArray = [];
var indexInput = 1;
outputArray[0] = inputArray[inputArray.length - 1];

while (indexInput < inputArray.length)
{
outputArray[indexInput] = inputArray[indexInput - 1];
indexInput = indexInput + 1;
}

return outputArray;

}

This function is supposed to create a new array by copying the input array and moving everything 1 index location to the right, also it takes the variable in the last index location and moves it to the front. So it would take an input array of 1 2 3 4 5 and the output array would be 5 1 2 3 4.


Now from what i can tell it does accomplish this it spits out 5 1 2 3 4, but i would like to feed that 5 1 2 3 4 output back into the function again so it would hopefully spit out 4 5 1 2 3. I just dont know how to go about doing that.

Im testing to see if that function actually does what i intend it to do and can do it more than once without screwing up.
 
Okay what ive got here:
Now from what i can tell it does accomplish this it spits out 5 1 2 3 4, but i would like to feed that 5 1 2 3 4 output back into the function again so it would hopefully spit out 4 5 1 2 3. I just dont know how to go about doing that.

Code:
var myArray = [1, 2, 3, 4, 5];
var newArray = right(right(myArray));
 
Code:
var myArray = [1, 2, 3, 4, 5];
var newArray = right(right(myArray));

lol how stupid am i, just store it as a variable doh... thanks for that, well it does seem to work as i intended as with a number of variables im getting 5 1 2 3 4 then 4 5 1 2 3 etc so thats fine. :thumbsup:
 
Back
Top