Nodejs Array Clean clean(deleteValue)

Here you can find the source of clean(deleteValue)

Method Source Code

Array.prototype.clean = function(deleteValue) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {
            this.splice(i, 1);/*w  ww  .j  a va2 s  .c  o m*/
            i--;
        }
    }
    return this;
};

function findNthDigit(arr) {
    var n = parseInt(arr[0]);
    var numberDigits = arr[1].toString().split('').clean('-').clean('.').reverse();
    var output = '';
    if (numberDigits[n - 1] != undefined){
       output = numberDigits[n - 1];
    } else {
       output = "The number doesn?t have " + n +  " digits";
    }
    return output;
}

console.log(findNthDigit([1, 6]));
console.log('\n');
console.log(findNthDigit([2, -55]));
console.log('\n');
console.log(findNthDigit([6, 923456]));
console.log('\n');
console.log(findNthDigit([3, 1451.78]));
console.log('\n');
console.log(findNthDigit([6, 888.88]));

Related

  1. clean(deleteValue)
    Array.prototype.clean = function(deleteValue) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] === deleteValue) {
                this.splice(i, 1);
                i--;
        return this;
    };
    ...
    
  2. clean(deleteValue)
    function rand(from,to)
        return Math.floor(Math.random()*(to-from+1)+from);
    Array.prototype.clean = function(deleteValue) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {         
          this.splice(i, 1);
          i--;
    ...
    
  3. clean(deleteValue)
    Array.prototype.clean = function(deleteValue) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {
          this.splice(i, 1);
          i--;
    };
    
  4. clean(deleteValue)
    function rand(min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min;
    function setToFixedVelocity(vec_x ,vec_y, fixedVelocity){
      z = (fixedVelocity) / (Math.pow((vec_x*vec_x)+(vec_y*vec_y),1/2));
      obj = {"x": vec_x*z, "y": vec_y*z}
      return obj
    ...
    
  5. clean(deleteValue)
    function rand(min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min;
    function setToFixedVelocity(vec_x ,vec_y, fixedVelocity){
      z = (fixedVelocity) / (Math.pow((vec_x*vec_x)+(vec_y*vec_y),1/2));
      obj = {"x": vec_x*z, "y": vec_y*z}
      return obj
    ...
    
  6. clean(deleteValue)
    Array.prototype.clean = function(deleteValue) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {
          this.splice(i, 1);
          i--;
      return this;
    };
    ...
    
  7. clean(deleteValue)
    var CURRENTTV = 1;
    var TYPE_TV_AD = 575;
    var TYPE_UPCOMING_EVENT = 574;
    var TYPE_PAST_EVENT = 576;
    Array.prototype.clean = function(deleteValue) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {         
          this.splice(i, 1);
          i--;
    ...
    
  8. clean(s)
    Array.prototype.clean = function (s) {
        var i = 0;
        for (var i = 0; i < this.length; i++) {
            if (this.hasOwnProperty(i)) {
                if (this[i] == s) {
                    this.splice(i, 1);
                    i = i-1;
        return this;
    };
    
  9. cleanPV(deleteValue)
    Array.prototype.cleanPV = function(deleteValue) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == deleteValue) {         
          this.splice(i, 1);
          i--;
      return this;
    };
    ...