curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6925e2068081f40f549ced1a.md
Given a string of an image in Markdown, return the equivalent HTML string.
A Markdown image has the following format: "". Where:
alt text is the description of the image (the alt attribute value).image_url is the source URL of the image (the src attribute value).Return a string of the HTML img tag with the src set to the image URL and the alt set to the alt text.
For example, given "" return '';
Note: The console may not display HTML tags in strings when logging messages — check the browser console to see logs with tags included.
parseImage("") should return ''.
assert.equal(parseImage(""), '');
parseImage("") should return ''.
assert.equal(parseImage(""), '');
parseImage("") should return ''.
assert.equal(parseImage(""), '');
function parseImage(markdown) {
return markdown;
}
function parseImage(markdown) {
const regex = /!\[(.*?)\]\((.*?)\)/;
const match = markdown.match(regex);
if (!match) return "";
const alt = match[1];
const src = match[2];
return ``;
}