Thursday, 17 August 2017

REMOVE RETURN VARIABLE REMOVE VARIABLE IN FUNCTION BRACKETS IN JAVA SCRIPT



--------------------------------------------------------------------------------------------------------------------
REMOVE RETURN VARIABLE IN JAVA SCRIPT
ReadMore:
http://fbgadgets.blogspot.co.uk/2017/07/quiz-script.html
https://www.w3schools.com/js/js_functions.asp
--------------------------------------------------------------------------------------------------------------------
<html>
<body>
<p id="demo"></p>
<script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script>
</body>
</html>
OR CHANHGE ABOVE CODE
<html>
<!-- https://www.w3schools.com/js/tryit.asp?filename=tryjs_functions -->
<p id="demo"></p>
<body>
<script>
function myFunction() {
var p1 = 4;
var p2 = 3;
var x =  p1 * p2;
alert(x)
document.getElementById("demo").innerHTML = x ;
}
myFunction();
</script>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
REMOVE VARIABLE IN FUNCTION BRACKETS IN JAVA SCRIPT
ReadMore:
http://fbgadgets.blogspot.co.uk/2017/07/quiz-script.html
--------------------------------------------------------------------------------------------------------------------
<html>
<body>
<script>
var firstArray = ["One","Two","Three","Four","Five","six","seven","eight","nine","ten"];
var newArray= new Array();
function randomizeArray(array){
var newArray = new Array();
while (array.length > 0){
newArray.push(array.splice(Math.floor(Math.random()*array.length), 1));
}
return newArray;
}
var randomArray = randomizeArray(firstArray);
document.write(randomArray);
</script>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
CHANGE ABOVE CODE
array <-------->firstArray
--------------------------------------------------------------------------------------------------------------------
<html>
<body>
<script>
var firstArray = ["One","Two","Three","Four","Five","six","seven","eight","nine","ten"];
var newArray= new Array();
function randomizeArray(){
var newArray = new Array();
while (firstArray.length > 0){
newArray.push(firstArray.splice(Math.floor(Math.random()*firstArray.length), 1));
}
return newArray;
}
var randomArray = randomizeArray(firstArray);
document.write(randomArray);
</script>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
CHANGE ABOVE CODE
HOW TO REMOVE EXTRA VARIABLE LIKE
HOW TO CHANGE 
document.write(randomArray);<------------>
document.getElementById("demo").innerHTML= randomizeArray(firstArray);
--------------------------------------------------------------------------------------------------------------------
<html>
<body>
<div id="demo"></div>
<script>
var firstArray = ["One","Two","Three","Four","Five","six","seven","eight","nine","ten"];
var newArray= new Array();
function randomizeArray(){
while (firstArray.length > 0){
newArray.push(firstArray.splice(Math.floor(Math.random()*firstArray.length), 1));
}
return newArray;
}
//SHOW CODE LINE OUTSIDE
document.getElementById("demo").innerHTML= randomizeArray(firstArray);
</script>
</body>
</html>
 --------------------------------------------------------------------------------------------------------------------
CODE WITHOUT FUNCTION WITHOUT WHILE LOOP
<div id="demo"></div>
<script>
var firstArray = ["One","Two","Three","Four","Five","six","seven","eight","nine","ten"];
firstArray.push(firstArray.splice(Math.floor(Math.random()*firstArray.length),1));
//SHOW CODE LINE OUTSIDE
document.getElementById("demo").innerHTML= firstArray

</script>
 --------------------------------------------------------------------------------------------------------------------
<div id="demo"></div>
<script>
//CODE WITHOUT FUNCTION
var firstArray = ["One","Two","Three","Four","Five","six","seven","eight","nine","ten"];
firstArray.push(firstArray.splice(Math.floor(Math.random()*firstArray.length), 1));
//SHOW CODE WITH GET ELEMENT ID
document.getElementById("demo").innerHTML=firstArray;
//SHOW CODE WITH DOCUMENT WRITE
document.write=firstArray;
//SHOW CODE WITH ALERT
alert(firstArray);
</script>

  --------------------------------------------------------------------------------------------------------------------





0 comments:

Post a Comment

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets