Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function parseData(str, callback) {
  2.  
  3. function recursiveFunction(obj) {
  4. var keysArray = Object.keys(obj);
  5.  
  6. for (var i = 0; i < keysArray.length; i++) {
  7. var key = keysArray[i];
  8. var value = obj[key];
  9.  
  10. if (value === Object(value)) {
  11. recursiveFunction(value);
  12. }
  13. else {
  14. if (key == 'title') {
  15. var title = value;
  16. }
  17.  
  18. if (key == 'extract') {
  19. var extract = value.replace(/(rn|n|r)/gm," ");
  20. callback(null, JSON.stringify({title: title, text: extract}));
  21. }
  22. }
  23. }
  24. }
  25.  
  26. recursiveFunction(str, callback(null, JSON.stringify({title: title, text: extract})));
  27. };
  28.  
  29. /parseData.js:29
  30. recursiveFunction(str, callback(null, JSON.stringify({title: title, text: extract})));
  31. ^
  32. ReferenceError: title is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement