Last active
December 23, 2017 14:15
-
-
Save trafficinc/1317f3a3e6cb35f6bf2fed2044f5a5e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<script> | |
var url = "http://www.mysite.com"; | |
var link = "Go to MySite"; | |
var html2 = sprintf( '<a href="%s">%s</a>', url, link ); | |
var html3 = sprintf( '<a href="%s">%d</a>', url, 34 ); | |
console.log(html2); | |
function sprintf( format ) | |
{ | |
for( var i=1; i < arguments.length; i++ ) { | |
if (Number.isInteger(arguments[i])) { | |
format = format.replace( /%d/, arguments[i] ); | |
} else { | |
format = format.replace( /%s/, arguments[i] ); | |
} | |
} | |
return format; | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment