Skip to content

Commit b73f4fa

Browse files
author
Jaskaran Singh
authored
Create ip_defanging.js
1 parent c2d7c1c commit b73f4fa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ip_defanging.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {string} address
3+
* @return {string}
4+
*/
5+
var defangIPaddr = function(address) {
6+
let defangedIpAddr = "";
7+
for(let i = 0; i < address.length; i++) {
8+
if(address[i] !== ".")
9+
defangedIpAddr = defangedIpAddr.concat(address[i]);
10+
else
11+
defangedIpAddr = defangedIpAddr.concat("[.]");
12+
}
13+
return defangedIpAddr;
14+
};

0 commit comments

Comments
 (0)