Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. const {
  4. computed
  5. } = Ember;
  6.  
  7. export default Ember.Component.extend({
  8. items: null,
  9.  
  10. random: computed('items', function(items) {
  11. const randomItems = [];
  12. const maxIndex = items.length - 1;
  13.  
  14. while(randomItems.length !== items.length) {
  15. console.log(`Find random item from source and place in destination`);
  16. const randomIndex = Math.floor(Math.random() * maxIndex);
  17. const randomItem = items[randomIndex];
  18.  
  19. // if(randomItems.indexOf(randomItem) !== -1) {
  20. randomItems.push(randomItem);
  21. // }
  22. }
  23.  
  24. return randomItems;
  25. })
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement