I'm trying to make a function that by passing certain arguments (numbers that act as indexes), with those numbers will change the indexes of a string (which I transform into an array) to CAPITAL LETTERS, but it does not return anything to me ..
Second explanation:
A string I transformed into an array to work with its indexes and then the arguments sent, will be used to specify the indices and thus these indices of the array of the STRING, transform them to uppercase and then return them as a string with the join method, and with the capitals applied -
function f() { // Funcion
var a = "hola"; // Variable
var e = a.split(''); // Transformo en array
var args = arguments.length; // Cantidad de argumentos
var i = 0; // Contador para el for
var finals = ""; // Variable para retornar string modificada
var maximo = Math.max.apply(null, arguments); // el argumento mas alto
for(;i<args;i++){ // recorro los argumentos
if(arguments[i] > e.length -1) { // Si algun argumento es mayor que los elementos del string, retorna undefined
finals = undefined; // undefined
}
else if(arguments[i] == e[i]) { // si el argumento recorrido es igual a algun indice de la string, por ejemplo ingresó como argumento 2 y cuando e[i] sea igual a e[2](mismo numero que el argumento) , la letra del string(que se transformó en array) sera modificada a MAYÚSCULA, y luego se le sumará el resto de la string con slice, desde el máximo de los argumentos(osea slice(comienzo,final))
finals += e[i].toUpperCase() + e.slice(maximo,e.length);
}
}
return finals; // vuelvo a meter la string que habia sido convertida en array, a un string con join()
}
var a = f(2);
console.log(a);