We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0efa425 commit 54f38edCopy full SHA for 54f38ed
solutions/1108-defanging-an-ip-address.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * 1108. Defanging an IP Address
3
+ * https://leetcode.com/problems/defanging-an-ip-address/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given a valid (IPv4) IP address, return a defanged version of that IP address.
7
8
+ * A defanged IP address replaces every period "." with "[.]".
9
+ */
10
+
11
12
+ * @param {string} address
13
+ * @return {string}
14
15
+var defangIPaddr = function(address) {
16
+ return address.replace(/\./g, '[.]');
17
+};
18
19
+// or...
20
21
22
23
24
25
26
+ return address.split('.').join('[.]');
27
0 commit comments