Comment formatting
Code ReviewMiddle
- Target
- find the 2 must-fix problems (3 in all)
- Your best
- Not played yet
Pull request
Formatted comments, stay signed in · feature/comment-formatting
Two small requests from support, in one pull request:
Comment.jsx: comments can use**bold**,_italics_and line breaks; authors get a delete button on their own comments.auth.js: the token survives a reload, so people are no longer signed out when they refresh.
Your teammate wrote it with an AI assistant and checked it with a few comments of their own. Review it before it is merged: comment on every line that has to change, and give each comment a category.
Hints
Your comments
Scoring: a comment finds a problem when it is on the problem's lines (or one line around them) and names its category. The score is the share of problems found, minus half a problem for each comment that finds nothing new. Find every must-fix problem, with no more such comments than there are problems, to complete the challenge. Only your first review is scored.
11export function Comment({ comment }) {
11// Comments may use **bold**, _italics_ and line breaks.
22function format(text) {
33 return text
44 .replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
55 .replace(/_(.+?)_/g, "<em>$1</em>")
66 .replace(/\n/g, "<br>");
77}
88
99export function Comment({ comment, canDelete, onDelete }) {
21010 return (
31111 <article className="comment">
41212 <header>
51313 <strong>{comment.author}</strong>
61414 <time dateTime={comment.createdAt}>{comment.date}</time>
1515 {canDelete && (
1616 <span className="comment-delete" onClick={() => onDelete(comment.id)}>
1717 ✕
1818 </span>
1919 )}
72020 </header>
88 <p className="comment-body">{comment.body}</p>
2121 <div className="comment-body" dangerouslySetInnerHTML={{ __html: format(comment.body) }} />
92222 </article>
102323 );
112424}