What is the duty of defining 'n' argument?

What is the duty of defining 'n' argument?
0

#1

Hi, I want to ask a questions. What is the duty of defining ‘n’ argument ? When I remove it doesn’t change anything.

function showDistro() { 
  var n=0;
  for (var i = 0; i < this.table.length; ++i) {
    if (this.table[i] != undefined) {
      console.log(i + ": " + this.table[i]); 
    }
  } 
}

#2

There isn’t any, it’s not used. As I have no idea what the code is or what it’s supposed to do, can’t even take a guess as to why it’s been left there (accidentally?) in the first place


#3

Actually, I want to ask for belowing code block. My questions is inside code at function of showDistro(). Maybe this code is helped

function HashTable(){
	this.table = new Array(137);
	this.simpleHash = simpleHash;
	this.showDistro = showDistro;
	this.put = put;
	// this.get = get;
}

function put(data){
	var pos = this.simpleHash(data);
	this.table[pos] = data;
}


function simpleHash(data){
	var total = 0;
	for(var i = 0; i < data.length; i++){
		total += data.charCodeAt(i);
	}
	return total % this.table.length;
}



function showDistro(){
	var n = 0;
	for(var i = 0; i < this.table.length; i++){
		if(this.table[i]!= undefined){
			console.log(i + ": " + this.table[i]);
		}
	}
}

var someNames = ["David", "Jennifer", "Donnie", "Raymond",
"Cynthia", "Mike", "Clayton", "Danny", "Jonathan"];

var hTable = new HashTable();
for(var i = 0; i < someNames.length; i++){
	hTable.put(someNames[i]);
}
hTable.showDistro();


#4

:man_shrugging: why do you need to know? Why not just delete it, given it doesn’t do anything and looks like it’s there by mistake?


#5

Ok thanks Dan. I m sorry for my insistance