Obtener nombre de variable JavaScript
const myFirstName = 'John'
Object.keys({myFirstName})[0]
// returns "myFirstName"
Worried Willet
const myFirstName = 'John'
Object.keys({myFirstName})[0]
// returns "myFirstName"
var a = [1, 3, 4, 3]
var b = [1, 5, 6, 7]
var c = [3, 4, 8, 9]
function arraySum(x, varName) {
var sum = 0
for (let i = 0; i < x.length; i++) {
sum += x[i]
}
console.log("sum of " + varName + " is " + sum)
}
arraySum(a, "a");