Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //delete question
  2. delQuest = ()=>{
  3. this.nameOfQuest = this.getName(questionList.questions, this.randQuest);
  4. delete questionList.questions[this.nameOfQuest];
  5. let validate = Object.keys(questionList.questions).length;
  6. if(validate===0){
  7. alert('molca dlo');
  8. }
  9. }
  10.  
  11. //get name of value
  12. getName = (obj, value)=>{
  13. value = JSON.stringify(value);
  14. return Object.keys(obj).find(key => JSON.stringify(obj[key]) === value);
  15. }
  16.  
  17. //random property from object
  18. randomProp = (obj)=>{
  19. let keys = Object.keys(obj)
  20. return obj[keys[keys.length * Math.random() << 0]]
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement