Build a full stack JavaScript app that is functionally similar to this: <ahref="https://sudoku-solver.freecodecamp.rocks/"target="_blank">https://sudoku-solver.freecodecamp.rocks/</a>. Working on this project will involve you writing your code using one of the following methods:
- Clone <ahref='https://github.com/freecodecamp/boilerplate-project-sudoku-solver'target='_blank'>this GitHub repo</a> and complete your project locally.
- Use <ahref='https://repl.it/github/freeCodeCamp/boilerplate-project-sudoku-solver'target='_blank'>our repl.it starter project</a> to complete your project.
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
- All puzzle logic can go into `/controllers/sudoku-solver.js`
- All routing logic can go into `/routes/api.js`
- See the `puzzle-strings.js` file in `/controllers` for some sample puzzles your application should solve
- To run the challenge tests on this page, set `NODE_ENV` to `test` without quotes in the `.env` file
- To run the tests in the console, use the command `npm run test`. To open the Repl.it console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
- text: You can `POST``/api/solve` with form data containing `puzzle` which will be a string containing a combination of numbers (1-9) and periods `.` to represent empty spaces. The returned object will contain a `solution` property with the solved puzzle.
const data = await fetch(getUserInput('url') + '/api/solve', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({notpuzzle: input})
});
const parsed = await data.json();
assert.property(parsed, 'error');
assert.equal(parsed.error, output);
}"
- text: If the puzzle submitted to `/api/solve` contains values which are not numbers or periods, the returned value will be `{ error:'Invalid characters in puzzle' }`
const data = await fetch(getUserInput('url') + '/api/solve', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({puzzle: input})
});
const parsed = await data.json();
assert.property(parsed, 'error');
assert.equal(parsed.error, output);
}"
- text: If the puzzle submitted to `/api/solve` is greater or less than 81 characters, the returned value will be `{ error:'Expected puzzle to be 81 characters long' }`
const data = await fetch(getUserInput('url') + '/api/solve', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({puzzle: input})
});
const parsed = await data.json();
assert.property(parsed, 'error');
assert.equal(parsed.error, output);
}"
- text: You can `POST` to `/api/check` an object containing `puzzle`, `coordinate`, and `value` where the `coordinate` is the letter A-I indicating the row, followed by a number 1-9 indicating the column, and `value` is a number from 1-9.
- text: The return value from the `POST` to `/api/check` will be an object containing a `valid` property, which is `true` if the number may be placed at the provided coordinate and `false` if the number may not. If false, the returned object will also contain a `conflict` property which is an array containing the strings `"row"`, `"column"`, and/or `"region"` depending on which makes the placement invalid.
- text: If the puzzle submitted to `/api/check` contains values which are not numbers or periods, the returned value will be `{ error:'Invalid characters in puzzle' }`
- text: If the puzzle submitted to `/api/check` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
- text: If the object submitted to `/api/check` is missing `puzzle`, `coordinate` or `value`, the returned value will be `{ error:Required field(s) missing }`