Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Do you know how to sum a set of numbers in an array?
  2. Your code doesn't work. You do not understand the basic concepts, as I was asking about. true and false shouldn't be strings, they're boolean values. Here are the results of your function: compare(["apple", "banana", "carrot"], "a"); // "false"compare(["apple", "banana", "carrot"], "apple"); // "false"compare(["apple", "banana", "carrot"], "banana"); // "false"compare(["apple", "banana", "carrot"], "0"); // "true"
  3. Ingolme

    jquery

    A function declaration doesn't ever execute, it's safe to have it outside of the ready() handler. The only reason you need ready() is to access HTML elements that would not have loaded yet.
  4. Ingolme

    jquery

    Another problem is that the function heidi() isn't global, it's not accessible from the element's onclick scope. Put the function declaration outside of the .ready() handler. The hilsen="heidi" syntax doesn't work in Javascript, that's a C++ / Java / PHP thing. If you want to give a default value then you'll have to set it inside the function: function heidi(hilsen) { if(typeof hilsen == "undefined") { hilsen = "heidi"; }
  5. Ingolme

    jquery

    I think the syntax highlighter is showing what your problem is. The word "lars" is outside of the attribute's value.
  6. Ingolme

    Help with header

    The <html> and <body> elements usually have some margin or padding on them by default. I usually put the following code in my stylesheets along with some other things: html, body { margin: 0; padding: 0;}
  7. I'm not joking, most of your trouble with more advanced concepts is that you seem to have a misunderstanding of much more basic concepts. I can ask you to do a simple task to show that you know some concepts: Make a function that takes two parameters: An array and a string. If the array has the string in it then return true. Return false if the string is not in the array.
  8. Don't use float: left if you want it centered. To center blocks, set margin: 0 auto Perhaps the banner image should actually be a centered background image so that you can avoid using position: absolute.
  9. It depends on whether your product is a client-side application or whether it's a server-side application. Imagine how it might be if this forum was purely Javascript-based. We get enough complaints about its functionality as it is.
  10. AJAX is a complement to forms, not a replacement of them.
  11. "Framework" and "library" refer to certain programs people made with normal Javascript. You shouldn't worry about frameworks and libraries. Begin by learning how to do basic programming: if, while, for, and function.
  12. It will send cookie data that belongs to one website to another website. This would only be a threat if data isn't sanitized before being displayed. It won't harm your computer, it is just a security threat that could potentially allow sensitive data to arrive to third parties.
  13. If the 100th floor doesn't destroy the macbook then we still have the information we wanted. The highest floor you can drop it from is 100 because there aren't any more floors. My method isn't the binary search method. A binary search would require seven macbooks and the problem says we only have two. I didn't describe my actual solution because I believe this is a homework question and giving the answer wouldn't help him learn.
  14. The simplest idea would be to start on the first floor and continue dropping from higher floors one by one until it breaks. Of course, the idea is to reduce the number of drops performed and the worst case scenario for this method is 100 drops so it's not good enough. If we had unlimited macbooks I'd start from floor 50, if it breaks, try floor 25, if it doesn't try floor 75. and repeat the procedure dividing the building into smaller sections. If I calculated correctly, the worst case scenario would be 7 drops for this method. Since we don't have unlimited macbooks we'll have to devise another method. I don't know if giving you my solution would help you learn anything. For the solution I've devised, the worst case scenario would require 51 drops but perhaps somebody more experienced than me knows a better way.
  15. If you do, then the prompt will appear, but you won't know what the user wrote. The value that the user gives is stored in the variable you assign prompt() to.
  16. guess is probably initialized to a string so that it doesn't have to be casted to a string in the first comparison. It's nothing really important prompt() is a function belonging to the Window object: http://www.w3schools.com/jsref/met_win_prompt.asp It returns the value that the user put into the prompt, which is assigned to the guess variable. prompt = ('Password?') wouldn't work, it would just assign the string "Password?" to a variable prompt (overwriting the original function prompt() in the process)
  17. Ingolme

    Help!

    If I told you "yes" or "no" you still wouldn't understand why. You have to find out what "calling" or "invoking" means. Learn about functions here: http://www.w3schools.com/js/js_functions.asp
  18. Ingolme

    Help!

    I have told you how to determine if a function is recursive or not. If it is calling itself then it is recursive.
  19. Ingolme

    Help!

    Arrays: http://www.w3schools.com/js/js_arrays.asp
  20. What does the error say?
  21. Ingolme

    New Member :)

    You have a question mark outside of the string which would cause a syntax error.
  22. Ingolme

    php

    Either you have already declared that function in another file, or you're including this file twice.
  23. Prototype is a perfectly accurate term for what it is. A prototype is a model on which copies are based. My opinion about your learning of Javascript is that you're having trouble on your own, you need to sign up to a Javascript course to learn it properly and to have a tutor who can monitor your progress. You are learning things out of order and trying to understand advanced things without understanding the basics.
  24. Ingolme

    json

    Make sure your JSON syntax is correct. All strings and property names must be delimited by double-quotes: { "property" : "value" } The following are incorrect: { "property" : 'value' } { property : "value" } { 'property' : "value" }
×
×
  • Create New...