My Wiki is not working

My Wiki is not working
0.0 0

#1

Been working on this project for awhile. I am not sure if its something I did wrong with the API .
I can’t get anything when trying to search…
Will be grateful if there is someone can help me take a look at my code.

Many thanks in advance!~

Here is the link


#2

Hello!

In your code you are missing the “t” in the word length.

for (i=0 ; i<arrTitle.lengh ; i++){
      html += "<h4><a target ='_blank' href = '"+ arrUrl[i] +"'> "+arrTitle[i]+"</a></h4>"+ arrDes[i];
      }//for loop

If you look above you will see you have spelled it “lengh” instead of the proper spelling of “length”. If you fix the spelling your code will run and work.

A quick tip. I would use console.log(); statements in various places as a way to test if your code reaches a certain point. For example, if you put a console statement inside the previous “if” statement and then inside your “for” loop, you’ll notice that it works in your “if” statement, but not the “for” loop. They are useful as a quick way to check if your program is even executing a block of code.

Let me know if you have any other questions.


#3

Thank you so much! It works now~~
but I have a question regarding the console.log();

Is this what you mean?

and then when I turn on Google web tool it showed something like this?


#4

Apologies for not getting back to you sooner, I have gotten very busy.

You are using console.log; and the correct format is console.log("place string or variable here to debug"); where you put whatever you need to debug inside the parenthesis. In your case it would be a simple “I made it here” text to know if that section of the JS is executed. It is also useful when debugging variables and objects as you can start to break them down into smaller pieces and look at each piece - mostly noticed with arrays.

Yes, you have the idea of it down. I would have placed one inside if(arrTitle[0] !== null){ and then inside the for (i=0... code blocks. If the code ran perfectly then both the console.log(); calls will run, if it cannot reach the for loop then your console.log(); in the for loop will not execute letting you know it wasn’t able to reach that part of the code during execution.

As I said above, it’s a pretty quick trick to see where your code executes and where it doesn’t. Sometimes it will save hours of debugging or breaking down a program if you’re in a rush.