Saturday, July 23, 2011

JavaScript Exercises - sort() of Array

example:
JavaScript Exercises - sort() of Array
<!DOCTYPE html>

<html>
<head>
<title>JavaScript Exercise</title>
<script type="text/javascript">

function exercise(){
var stringsource = "A man and a pen";
var result = "sort() of Array= " + stringsource.split(" ").sort() + "\n";

alert(result);
}


function htmlonload(){
exercise();
}
</script>
</head>
<body onload="htmlonload();">
JavaScript Exercise
</body>
</html>


No comments:

Post a Comment