Home > front end >  The values in the array is a consecutive Numbers
The values in the array is a consecutive Numbers

Time:10-09

Such arrays [" F8 ", "F6", "F4", "F3", "F2", "B1" and "B3"].
Need to request a letter after the array is adjacent Numbers, if not need to add the letters + adjacent Numbers on
For instance should deal with the above array into: [" F8 ", "F7", "F6", "F5", "F4", "F3", "F2", "F1", "B1", "B2", "B3"].

CodePudding user response:

F1 and neighbouring B1? This is the number of floors? There are other letters?

CodePudding user response:




<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
<meta HTTP - equiv="X - UA - Compatible" content="ie=edge" & gt;
Document
<script>
//the reverse flip flip any array functions
The function reverse (arr) {
Var newArr=[];
For (var I=arr. Length - 1; I & gt;=0; I -) {
=arr newArr [newArr length] [I];
}
Return newArr;
}
Var arr1=reverse ([" F8 ", "F6", "F4", "F3", "F2", "B1" and "B3"]);
The console. The log (arr1);
</script>


<body>



  • Related