0

I'm getting a text file as API response from here https://api.pwnedpasswords.com/range/D0597 that looks like this

007F24D71AC210875C58951F5D99ACC71D2:3
0097880A0B749B59A5F7FD0D943A133ADE1:4
00CAEC74DE2FA10428E6D3FAD065D53B865:4
00F8C45A33243D0A4FD293DC70130E82E00:1
024556F4CB4A1DA178A6EC4E43ECED22467:1
030BA417A72B878EC629BD585705D306260:1
03664676C5A123BE6927DB6BAC5F5427468:1
0491953CF08D183806C28DB827835D27348:1
04BA7B823BBB772A8172F94A757AAF59A39:2
04D3C208B89E12C60AB12900690E86C13DA:1
06856BA40BCB6BCE13C40F271487F347BA5:1
071E3D06232DEA85E297102F6037164C033:5

and I need to loop through and check if the value of an input is included in the list of first item. If present I need to show the second value after ":".

I was trying to use split() for new line and ":" and iterate but kind of got lost.

Butri
  • 204
  • 3
  • 11

1 Answers1

1
// data is your text file
var foo = data.split("\n"),
    bar = "your input";

Object.keys(foo).forEach(function(key) {

    if (foo[key].split(":")[0] === bar) {
        console.log(foo[key].split(":")[1]);
    }

});
bob
  • 55
  • 6