Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   let standardKeyWordsResults = (ele && ele.WordStatistic && ele.WordStatistic.StandardKeyWordsResults && ele.WordStatistic.Results) ? ele.WordStatistic.StandardKeyWordsResults : [];
  2.         console.log('abc',standardKeyWordsResults)
  3.         if (standardKeyWordsResults.length > 0) {
  4.  
  5.           // convert json object into an array to display as a list of key words
  6.           // let keys = Object.keys(standardKeyWordsResults)
  7.           // keys.forEach(key => {
  8.           //   if (standardKeyWordsResults[key] === 0) {
  9.           //     delete standardKeyWordsResults[key]
  10.           //   }
  11.           // })
  12.           let stringifyContent = JSON.stringify(standardKeyWordsResults);
  13.        
  14.           stringifyContent = stringifyContent.replace(/['"]+/g, ''); // replace double quotes
  15.           stringifyContent = stringifyContent.replace(/[{}]/g, ""); // remove braces
  16.          
  17.           // set as an array
  18.           let splittedArray = stringifyContent.split(',').filter(elem => elem !== "")
  19.           console.log('abc',splittedArray)
  20.           ele.WordStatistic.StandardKeyWordsResults = splittedArray.length > 0 ? splittedArray : []
  21.         } else {
  22.           ele.WordStatistic.StandardKeyWordsResults = []
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement