v1
1/21/2021 by lamik -00
disable setup HTML
Setup HTML
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
disable setup JavaScript
Setup JavaScript
let a= [
  {name:"John0", lines:"0,19,26,96"},
  {name:"John1", lines:"1,19,26,96"},
  {name:"John2", lines:"2,19,26,96"},
  {name:"John3", lines:"3,19,26,96"},
  {name:"John4", lines:"4,19,26,96"},
  {name:"John5", lines:"5,19,26,96"},
  {name:"John6", lines:"6,19,26,96"},
  {name:"John7", lines:"7,19,26,96"},
  {name:"John8", lines:"8,19,26,96"},
  {name:"John9", lines:"9,19,26,96"},
]

let n = "Kristian";
delete caserun single casemove downdrag and drop case


ready



function A(arr, name) {
  let idx = arr.findIndex(o => o.name==name);
  if(idx>=0) arr.splice(idx, 1);
  return arr;
}

A(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function B(arr, name) {
  let idx = arr.findIndex(o => o.name==name);
  return idx<0 ? arr : arr.slice(0,idx).concat(arr.slice(idx+1,arr.length));
}

B(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function C(arr, name) {
  let idx = arr.findIndex(o => o.name==name);
  delete arr[idx];
  return arr;
}

C(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function D(arr, name) {
  return arr.filter(el => el.name != name);
}

D(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function E(arr, name) {
  let result = [];
  arr.forEach(o => o.name==name || result.push(o));
  return result;
}

E(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function F(arr, name) {
  return _.reject(arr, el => el.name == name);
}

F(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function G(arr, name) {
  let o = arr.find(o => o.name==name);
  return _.without(arr,o);
}

G(a,n);
delete caserun single casemove upmove downdrag and drop case


ready



function H(arr, name) {
  $.each(arr, function(i){
      if(arr[i].name === 'Kristian') {
          arr.splice(i,1);
          return false;
      }
  });
  return arr;
}

H(a,n);
delete caserun single casemove updrag and drop case


ready



function I(arr, name) {
  return $.grep(arr,o => o.name!=name);
}

I(a,n);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN