Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. /**
  2. * Created by Marina on 19.06.2016 г..
  3. */
  4. "use strict";
  5. setIndex(['3', '0 - 5', '1 – 6', '2 – 7']);
  6. function setIndex(text){
  7. let count=Number(text[0]);
  8. let newArray=[];
  9. for(let i=1;i<text.length;i++){
  10. let temp=text[i].split(' - ');
  11. let index=temp[0];
  12. let value=temp[1];
  13. newArray[index]=value;
  14. }
  15. for(let j=0;j<count;j++){
  16. if(newArray[j]==undefined){
  17. console.log(0);
  18. }
  19. else{
  20. console.log(newArray[j]);
  21. }
  22.  
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement