How to correctly insert data into a queue in JavaScript?

0

I have to insert some data into a queue, and I have the following functions:

  

InsertPos - which will insert the position of the data,

     

RemovePos - which will remove the position of the die,

     

ReadList - which will read the list that has been added.

My code:

<!DOCTYPE html>
<html>
<head>
<!-- <title>Web Page Design</title> -->
<script type = "text/javascript" />
function Lista(){

this.minhalista= new Array();
this.InserirPos= function(obj, pos){
pos--;
if(pos< this.minhalista.length) {
this.minhalista.splice(0,0,obj);
}
else{ 
alert("Posição invalida");
}
}

this.RemoverPos = function(pos){
if(pos<(this.minhalista.length+1)) {
this.minhalista.splice((pos-1),1);
}
}

this.LerLista = function(){
if(this.minhalista.length>0){
for(co=0;co< this.minhalista.length;co++)
document.write(this.minhalista[co]+"</br>");
}else{
alert("Não há objetos na Lista");
}
}
</script>
</head>

<body>

<h1>Exemplo Lista</h1>
<script type ="text/javascript" />

var minhalista= new Lista();

minhafila.InserirPos(prompt ("Digite um texto : "));
minhafila.InserirPos(prompt ("Digite um texto : "));
minhafila.InserirPos(prompt ("Digite um texto : "));

minhalista.LerLista();
</script>

</body>

</html>

The problem is that by putting in the HTML part to insert the positions and data, it does not happen anything and I can not ask the user to enter the numbers, and even after this, it does not appear on the screen the numbers. / p>

How can I fix this, and promptly and correctly insert the data into the queue?

    
asked by anonymous 25.10.2017 / 00:55

0 answers