Created
March 15, 2015 19:40
-
-
Save jamc92/6f51764ec35830d61050 to your computer and use it in GitHub Desktop.
JS - Inheritance with functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Inheritance from a build Function in JS</title> | |
<script type="text/javascript"> | |
String.prototype.reverse = function() { | |
var salida = ""; | |
for (var i = this.length-1; i >= 0; i--) { | |
salida += this.substr(i, 1); | |
} | |
return salida; | |
} | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var enString = prompt("Introduce your reverse text: "); | |
document.write(enString.reverse()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment