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 267 views
1 answer 163 views
1 answer 179 views
4 answers 274 views
1 answer 176 views
1 answer 165 views
1 answer 188 views
...