JSFiddle - React, Tailwind, and code Playground

by borisjavier

HTML

<button id="myBtn">My Button</button>

<p id="theThing">Click the button below to disable the button above.</p>

<button onclick="myFunction()">Try it</button>

JavaScript

function myFunction() {
	const theThing = document.getElementById('theThing');
	const textSend = 'Golden-notes:1jYN4ybAeSs52KUzKToJuX1VcoHsfakLD&amount=38564$sndr=Y2FsZWJkYXZpZGJhcnJlcmFAZ21haWwuY29t';
      var col = textSend.indexOf(":");
      var amp = textSend.indexOf("&");
      var ant = textSend.indexOf("$");
      var cpone = Number(col) + 1;
      var eq = textSend.indexOf("=");
      var ams = Number(eq) + 1;
      var sndr = textSend.indexOf("$sndr=") + 6;
      var res = textSend.substring(cpone, amp); //
      var amount = textSend.substring(ams, ant); //Number(textSend.substring(ams, sndr));
      var senderMail = textSend.substring(sndr, textSend.length);
      
      theThing.innerHTML = 'Dirección: ' + res + '<br> y la cantidad es: ' + amount + '<br> y el correoEn es ' + senderMail
}