Tell us what’s happening:
The console parse the output as html tag, not string literal.
For example,
const cannotSee = (input) => return input
console.log(cannotSee('<span>abc</span>'))
will print 'abc' not '<span>abc</span>'
This makes the answer hard to match the expectation.
Your code so far
function extractAttributes(element) {
const s = element.trim()
const re = /\s+([^\s=]+)=("[^"]*"|'[^']*')>/g
return [].concat(...[...s.match(re)].map(m => [m[1], m[2]]))
}
console.log(extractAttributes('<span class="red"></span>'))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Daily Coding Challenge - HTML Attribute Extractor
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-10-19
