Cambios de divisas ARA

Cantidad:
De:
Peso colombiano (COP) Bolívar venezolano (VES) Dólar estadounidense (USD)
A:
Dólar estadounidense (USD) Bolívar venezolano (VES) Peso colombiano (COP)
Convertir
Enviar a WhatsApp
let lastConversion = »; function convertCurrency() { const amount = parseFloat(document.getElementById(‘amount’).value); const from = document.getElementById(‘from’).value; const to = document.getElementById(‘to’).value; const result = document.getElementById(‘result’); const whatsappButton = document.getElementById(‘whatsappButton’); if (!amount || amount <= 0) { result.textContent = 'Ingresa una cantidad válida.'; whatsappButton.disabled = true; lastConversion = ''; return; } if (from === to) { result.textContent = `${amount} ${from} = ${amount} ${to}`; lastConversion = `${amount} ${from} = ${amount} ${to}`; whatsappButton.disabled = false; return; } // Tasas fijas (puedes reemplazarlas por una API real si lo deseas) const rates = { COP: { VES: 10, USD: 1 / 3900 }, VES: { COP: 0.1, USD: 0.1 / 3900 }, USD: { COP: 3900, VES: 39000 } }; let converted; if (rates[from] && rates[from][to]) { converted = amount * rates[from][to]; } else if (rates[to] && rates[to][from]) { converted = amount / rates[to][from]; } else { result.textContent = 'Conversión no soportada.'; whatsappButton.disabled = true; lastConversion = ''; return; } const formatted = converted.toLocaleString(undefined, { maximumFractionDigits: 2 }); result.textContent = `${amount} ${from} = ${formatted} ${to}`; lastConversion = `${amount} ${from} a ${to}`; whatsappButton.disabled = false; } function sendToWhatsApp() { if (!lastConversion) return; const message = `Hola, quiero cambiar ${lastConversion}`; const encodedMessage = encodeURIComponent(message); const whatsappURL = `https://wa.me/573219943433?text=${encodedMessage}`; window.open(whatsappURL, '_blank'); }