Skip to content

Commit

Permalink
include a final solution exercise 05
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucia86 committed Nov 21, 2023
1 parent 80af046 commit 12237f8
Show file tree
Hide file tree
Showing 4 changed files with 3,653 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { parse } = require('../address-parser');

describe('Address Parser', () => {
describe('Address parser', () => {
test('should parse correctly', () => {
expect(parse("I want to to order: 3 books to address: 112 street city here is my payment info: cardnumber")
).toEqual({
order: "3 books",
address: "112 street city",
payment: "cardnumber",
});
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.parse = function parseOrder(order) {
const match = order.match(/order:\s(?<order>\w+\s\w+).*address:\s(?<address>\w+\s\w+\s\w+).*payment info:\s(?<payment>\w+)/)
return match.groups;
}
Loading

0 comments on commit 12237f8

Please sign in to comment.