Defanging an IP Address

Easy

A defanged version of an IP address replaces every . with [.].

Return the defanged version of address.

Example 1

defangIPaddr()
Input
address = "1.1.1.1"
Output
"1[.]1[.]1[.]1"

Example 2

defangIPaddr()
Input
address = "255.100.50.0"
Output
"255[.]100[.]50[.]0"
Constraints
`address` is a valid IPv4 address.

Topics

Strings

Implement defangIPaddr in the editor and return the answer — printing it is never graded.