Tell us what’s happening:
Why am I failing my peek and pop test? for the pop case I literally used Array.pop() and it still failed;
Your code so far
function Stack() {
var collection = [];
this.print = function() {
console.log(collection);
};
// Only change code below this line
this.peek = function(){
var temp = collection.pop();
collection.push(temp);
return temp;
}
this.push = function(){
}
this.pop = function(){
console.log(collection);
var temp = collection.pop();
console.log(collection);
return temp;
}
this.isEmpty = function(){
if(collection.length == 0){
return true;
}
return false;
}
this.clear = function(){
collection = [];
}
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/data-structures/create-a-stack-class