Remove Element - Incorrect judgement with Javascript?

  • -1

    my codes are as below:

    var removeElement = function(nums, val) {
        for(var i=0,newLen=nums.length;i<nums.length;i++){
                newLen --;
        return newLen;
    var removeElement = function(nums, val) {
         return nums.filter(function(e){
             return e != val;

    Did I really get the wrong comprehension of this question or is the judgement system malfunctioning? I tried both of my solutions and the system just responded WRONG ANSWER... Isn't the question asking me to compute the new length of the filtered array???
    Please help point out any mistake if any, Thanks!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.