Javascript Project to Defang IP Address Full Project For Beginners

 

 

script.js

 

 

<script>

// Javascript implementation to find the
// defanged version of the IP address

// Function to generate a
// defanged version of IP address.
function GeberateDefangIP(str)
{
	var defangIP = "";
	
	// Loop to iterate over the
	// characters of the string
	str.split('').forEach(function(letter) {
		(letter == '.') ? defangIP += "[.]" :
					defangIP += letter; })

	return defangIP;
}

// Driven Code
var str = "255.100.50.0";
document.write( GeberateDefangIP(str));

</script>

Leave a Reply