How to remove item from array of integers in JavaScript

3 Answers

0 votes
<!DOCTYPE html>
<html>
<head></head>
<body>

<script type="text/javascript">
var arr = [1, 2, 3, 2, 5, 6, 6, 2];

arr.splice(3, 1);

for (var i = 0; i < arr.length; i++) 
     document.write(arr[i] + " ");
</script>

</body>
</html>

<!--
run: 

1 2 3 5 6 6 2  

-->

 



answered Feb 13, 2016 by avibootz
0 votes
<!DOCTYPE html>
<html>
<head></head>
<body>

<script type="text/javascript">
var arr = [1, 2, 3, 2, 5, 6, 6, 2];

arr.splice(1, 1);

for (var i = 0; i < arr.length; i++) 
     document.write(arr[i] + " ");
</script>

</body>
</html>

<!--
run: 

1 3 2 5 6 6 2   

-->

 



answered Feb 14, 2016 by avibootz
0 votes
<!DOCTYPE html>
<html>
<head></head>
<body>

<script type="text/javascript">
var arr = [1, 2, 3, 2, 5, 6, 6, 2];

arr.splice(0, 2);

for (var i = 0; i < arr.length; i++) 
     document.write(arr[i] + " ");
</script>

</body>
</html>

<!--
run: 

3 2 5 6 6 2   

-->

 



answered Feb 14, 2016 by avibootz

Related questions

3 answers 430 views
1 answer 256 views
1 answer 272 views
4 answers 461 views
1 answer 287 views
1 answer 254 views
1 answer 280 views
...