JavaScript - Arrays

preview_player
Показать описание
JavaScript - Arrays
Lecture By: Mr. Anadi Sharma, Tutorials Point India Private Limited
Рекомендации по теме
Комментарии
Автор

very good videos bro! do you also happen to have videos on python?

googoldata
Автор

Hi,


i have tried the sorting of array but it didn't work, Can you please help me


var ar = [7, 2, 8, 1, 3, 4];
var temp, i, j;
document.write("before sorting <br/>")
for (i=0; i<6;i++){
document.write(ar[i] +"<br/>");
}//for bubble sorting the loop should execute n*(n-1) times where n is length of an array

for ( i=0; i<6; i++ ){
for( j=0; j<5;j++)
{
if (ar[j]>ar[j+1])
{
temp = a[j];
a[j]= a[j+1];
a[j+1]=temp;
}
}
}
// a b c, , c=a, a=b, b=c
document.write("after sorting <br/>")
for (i=0; i<6;i++){
document.write(ar[i] +"<br/>");
}

anamika
visit shbcf.ru