TL;DR - Need help parsing the downloaded solution to understandble js
So i’ve finished all the basic js and es6, wanted to do a review annnnnd it’s gone,
I can’t view my old solutions (they don’t appear on fcc, only in green, so i downloaded them), the downloaded file is in json annd since it’s json i reallly cant understand anything written…
I just want to review my solutions… any help guys?
If you’re talking the file that you can download from your settings page, I believe that it only contains the solutions to your project challenges. The lesson challenges give you the opportunity to download your solution when you submit them, but they aren’t saved by FCC.
Exactly , i used it as an alternative to not being able to see my old solutions.
Now i have them downloaded, but i’m unable to see what’s inside due to the json format…
This is what i need help with,
I need to be able to see my old solutions, could you help me out Ariel?
You aren’t listening. The only old solutions that would be there are the projects at the end of sections. It does not include solutions that are not linked to elsewhere on the settings page.
Yes, i know but i’m not talking about the project solutions saved on the page of fcc…
I’m talking about parsing the json file to js so i could Read them
like this is what i have:
{"index.js":"// Setup\nvar testObj = {\n \"an entree\": \"hamburger\",\n \"my side\": \"veggies\",\n \"the drink\": \"water\"\n};\n\n// Only change code below this line\n\nvar entreeValue = testObj[\"an entree\"]; // Change this line\nvar drinkValue = testObj[\"the drink\"]; // Change this line"}
If the JSON file does include the challenges you want, then you need to find the key for the challenge you’re interested in. The value will be the solution code in the form of a string. When you parse the string all of the escaped characters will be presented as their parsed counterparts.
Hi, I’m not sure why the answers are being provided in this format. I found it pretty confusing and not a good user experience. I wound up creating a solutions.html file with code that parses the downloaded solution:
<!-- HTML boilerplate -->
<body>
<script>
var obj = // Paste your solution text here
console.log(obj[Object.keys(obj)[0]]);
</script>
</body>
If you open the page with a browser it will log the solution in the console in a readable format. Even this isn’t terribly helpful though, since the console doesn’t highlight syntax or allow easy editing. The best approach is probably to bypass the download button altogether and just copy and paste your answer into your favorite IDE and save from there. Here is a pen (make sure to open console to view solution).
Escape characters are necessary for formatting strings in JavaScript. JSON is JavaScript Object Notation. In order for the code to show up in the editor window broken into lines with indentation, the escape characters need to be there. Otherwise it would all be one long line.