Advertisement
Guest User

Untitled

a guest
Jun 12th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onload = function() {
  2.     // all your stuff that should execute on page load underneath here
  3.     write_added_text(); // functions returns nothing, only doing it's own stuff
  4.  
  5.  
  6.  
  7.     // another example
  8.     document.write(get_added_text()); // get_added_text will return something
  9. }
  10.  
  11. function write_added_text() {
  12.     var a = "Hello";
  13.     var b = "World";
  14.     var merged_text = a + b;
  15.     document.write(merged_text);
  16.     // no return here, therefore document.write(write_added_text) wont do much as document.write wont get any string to write
  17. }
  18.  
  19.  
  20. //function underneath here is an example of returning values
  21.  
  22. function get_added_text() {
  23.     var a = "Fuck";
  24.     var b = "HAHA HE SAID FUCK, HOMODICK";
  25.     return a + b; // we dont need to make another variable to return our desired end result. just returning is like this will work as well 
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement