Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload = function() {
- // all your stuff that should execute on page load underneath here
- write_added_text(); // functions returns nothing, only doing it's own stuff
- // another example
- document.write(get_added_text()); // get_added_text will return something
- }
- function write_added_text() {
- var a = "Hello";
- var b = "World";
- var merged_text = a + b;
- document.write(merged_text);
- // no return here, therefore document.write(write_added_text) wont do much as document.write wont get any string to write
- }
- //function underneath here is an example of returning values
- function get_added_text() {
- var a = "Fuck";
- var b = "HAHA HE SAID FUCK, HOMODICK";
- 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
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement