var categorias={
km: [0, 0, 0, 0, 0],
dinero: [0, 0, 0, 0, 0]
}
var max = 0;
do {
var cat = parseInt(prompt("Ingrese categoría:"));
var km = parseFloat(prompt("Ingrese kilometraje:"));
var din = parseFloat(prompt("Ingrese monto:"));
var conf = confirm("Desea continuar cargando?");
categorias.km[cat-1] += km;
if (din > max){
max = din;
categorias.dinero[cat-1] = max;
indexMax = cat;
}
}while(conf == true);
for (var i = 0; i < categorias.km.length; i++) {
document.write("Los Km. acumulados para categoría " + (i+1) + " son: " + categorias.km[i] + " Kms." + "<br />");
};
document.write("La categoría con viaje de mayor monto es: " + indexMax);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.