JSFiddle - React, Tailwind, and code Playground

by Krishna Ananthi

JavaScript

/** arr = [  73, 32, 56, 11, 96 ] 
Insert at position 3 value 63, Inserting into same array at given index without using built(utility) in functions
arr = [  73, 32, 63, 56,  11, 96 ] **/
function insert(a,ele,pos){
	for(let i=a.length;i>pos-1;i--)
  	a[i]=a[i-1]
  a[pos-1]= ele;
  return a;
}

console.log(insert([1,2,3,4,5],33,3));