working on it ...

Filters

Explore Public Snippets

Sort by

Found 21 snippets

    public by LaurenceTamatea  2636  8  4  0

    Square Root Function

    Square root of the sum of four parameters
     <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <title>JS Bin</title>
    </head>
    <body>
    
      <script>
        
        function simpleMath(a,b,c,d) {
          
          return(Math.sqrt) (4+5+6+7);
        }
        
        var q = simpleMath();
          alert(q);
      </script>
      
    </body>
    </html>          

    public by LaurenceTamatea  4194  1  4  0

    Variable Declaration After Function

      <script>
    
    function sumFunction (a, b) {
    	return (a+b);
    }
    	
    	var x = sumFunction (4, 2);
    	document.write (x);
    
    
    </script>
    
    

    public by LaurenceTamatea  2992  1  4  0

    Variable Declaration Before Function

    <script>
    
     var sum = addNumbers (23,2342,23424);
    	document.write (sum);
    
    function addNumbers (x,y,z) {
      
    	var result = x*y*z;
    	
    	return result;
    
    }                     
    
    </script>
    
    // or //
    
    
    <script>
     
    var result = addNumbers (2,3,4);
    	alert(result);
    	
    function addNumbers (a, b, c) {
    	
    	return (a + b + c);
    	}
    
    </script>            

    public by LaurenceTamatea  2134  2  4  0

    Create New Instance of an Object Using This.

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
    	<title>STANDARD TEMPLATE</title>
    	<meta charset="utf-8">
    	<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    	<style>
    
    	</style>
    
    	<script>
    		function trucks(brand, color) {
    			this.brand = brand;
    			this.color = color;
    			//we are working with this curent object//
    			//constructor function, is a blueprint for a function//
    		}
    
    		var mechanics = new trucks("Mac", "Blue");
    		var performance = new trucks("Mercedes Benz", "Silver");
    
    
    		//creating a new instance of an object (unlimited) with two properties//
    		//variable can be an object too//
    	</script>
    
    </head>
    
    <body>
    
    	<div>Standard Index Template</div>
    
    
    	<script>
    		document.write(mechanics.brand);
    		document.write(performance.color);
    
    		//name of the object and a property that we want to access//
    	</script>
    
    
    </body>
    
    </html>             

    public by LaurenceTamatea  2426  0  4  -1

    Strength Length

    Objects have properties and methods using the dot separator
     <!DOCTYPE html>
    <html lang="en">
    
    	<head>
    		<title>STANDARD TEMPLATE</title>
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    		<style> </style>
    	</head>
    
    	<body>
    
    <div>OBJECT ORIENTED PROGRAMING</div>
    
    
    		<script>
    
    
    		//dat with its own properties and methods//
    
    		var passenger = "I am passenger 3b";
    
    		passenger.length;
    		document.write (passenger.length); //length is a property of the passenger object//
    
    		//document is an object and write is a method//
    
    		</script>
    
        </body>
    
        </html>
                

    public by LaurenceTamatea  2428  2  4  0

    onMouseOver & onMouseOut

    Basic even handlers
    <!DOCTYPE html>
    <html lang="en">
    
    	<head>
    		<title>STANDARD TEMPLATE</title>
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    		<style> </style>
    	</head>
    
    	<body>
    
    <div>On Mouseover</div>
    
    	<a href="http://baudrillardsmatrix.info" onMouseOver="alert('It Worked!')">Place Your Cursor Here</a>
    
    
    		<script>
    		//you can also use onMouseOut for when you take your cursor away from the link//
    
    		</script>
    
    
    
        </body>
    
        </html>

    public by LaurenceTamatea  2374  1  4  0

    Event Handler onClick

     <!DOCTYPE html>
    <html lang="en">
    
    	<head>
    		<title>STANDARD TEMPLATE</title>
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    		<style> </style>
    	</head>
    
    	<body>
    
    <div>Event Handlers</div>
    
    
    		<form>
    			<input type="button" value="click me" onClick="alert('Hacked!');"/>
    
    		</form>
    
    		<script>
    		//end the js statment with a semi-colon//
    		//double quotation markets for attributes and single for JS//
    		//don't need to put the script between the script tags.//
    
    
    		</script>
        </body>
    
        </html>                       

    public by LaurenceTamatea  2233  8  4  -1

    Do While Loop

    Runs the code until the condition is met.
     <!DOCTYPE html>
    <html lang="en">
    
    	<head>
    		<title>STANDARD TEMPLATE</title>
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    		<style> </style>
    	</head>
    
    	<body>
    
    <div>Do While Loop</div>
    
    
    		<script>
    //runs the code until it gets to the condition which is eequal to or less than 30.//
    
    		var passengers=12; //if this var value was higher than the condition it will run once first//
    
    		do {
    			document.write (passengers + " There are more and more passengers? <br />");
    			passengers++;
    		}  while (passengers<=30);
    
    
    		</script>
    
        </body>
    
        </html>           

    public by LaurenceTamatea  1804  0  4  0

    While Loop

     <!DOCTYPE html>
    <html lang="en">
    
    	<head>
    		<title>STANDARD TEMPLATE</title>
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    		<style> </style>
    	</head>
    
    	<body>
    
    <div>Standard Index Template</div>
    
    
    		<script>
    
    		var passengerlist=1;
    
    		while (passengerlist<99) {
    			document.write("The passenger list is long today <br />");
    			passengerlist++; //while passengers is less than 99 it will run the code//
    		}
    
    
    		</script>
    
        </body>
    
        </html>          

    public by LaurenceTamatea  1874  0  4  0

    For Loop

     <!DOCTYPE html>
    <html lang="en">
    
    	<head>
    		<title>STANDARD TEMPLATE</title>
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    		<style> </style>
    	</head>
    
    	<body>
    
    <div>Standard Index Template</div>
    
    
    		<script>
    
    
    		for (x=0; x<10; x+=2) {
    			document.write("I am printed out five times<br />");
          /*for takes three conditions in the variable. Start point, end point and
    			how much the value increments by. Here it is 2. You could go x++*/
    	}
    
    		</script>
    
        </body>
    
        </html>
    • Public Snippets
    • Channels Snippets