This is my revised version of the solution. I have eliminated the need for jQuery, encapsulated the functionality within a function, and incorporated some ES6 features.
<html>
<head><title>Find My IP Address</title></head>
<body><h3 class='ipAdd'>My IP Address : <h3></body>
<script> "use strict";
window.RTCPeerConnection = window.RTCPeerConnection ||
window.mozRTCPeerConnection ||
window.webkitRTCPeerConnection;
function getIPAddress (callback) {
// Calls the callback function with the local host IP address found
// using RTC functions. We cannot simply return the IP address
// because the RTC functions are asynchronous.
var pc = new RTCPeerConnection ({iceServers: []}),
noop = () => {};
pc.onicecandidate = ice =>
callback = callback ((ice = ice && ice.candidate && ice.candidate.candidate)
? ice.match (/(\d{1,3}(\.\d{1,3}){3}|[a-f\d]{1,4}(:[a-f\d]{1,4}){7})/)[1]
: 'unavailable') || noop;
pc.createDataChannel ("");
pc.createOffer (pc.setLocalDescription.bind (pc), noop);
};
getIPAddress (address => { document.querySelector ('.ipAdd').innerHTML += address; });
</script>
</html>