Skip to content
FrontDepth, Home

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.

      1export function Comment({ comment }) {
      1// Comments may use **bold**, _italics_ and line breaks.
      2function format(text) {
      3 return text
      4 .replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
      5 .replace(/_(.+?)_/g, "<em>$1</em>")
      6 .replace(/\n/g, "<br>");
      7}
      8
      9export function Comment({ comment, canDelete, onDelete }) {
      10 return (
      11 <article className="comment">
      12 <header>
      13 <strong>{comment.author}</strong>
      14 <time dateTime={comment.createdAt}>{comment.date}</time>
      15 {canDelete && (
      16 <span className="comment-delete" onClick={() => onDelete(comment.id)}>
      17 ✕
      18 </span>
      19 )}
      20 </header>
      8 <p className="comment-body">{comment.body}</p>
      21 <div className="comment-body" dangerouslySetInnerHTML={{ __html: format(comment.body) }} />
      22 </article>
      23 );
      24}