ips in range typescript

The solution for “ips in range typescript” can be found here. The following code will assist you in solving the problem.

// Returns the number of ips between ip1 and ip2
function ipsInRange(ip1: string, ip2: string): number {

const ip1Bin: string = ip1.split(‘.’).map((p) => parseInt(p).toString(2).padStart(8, ‘0’)).join(”);
const ip2Bin: string = ip2.split(‘.’).map((p) => parseInt(p).toString(2).padStart(8, ‘0’)).join(”);

return parseInt(ip2Bin, 2) – parseInt(ip1Bin, 2);

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

inline scripts encapsulated in