diff --git a/find-tag.js b/find-tag.js new file mode 100644 index 0000000..d8e8998 --- /dev/null +++ b/find-tag.js @@ -0,0 +1,28 @@ + +const findTag = function(text) { + let tagStarted = false + let tag = "" + for (const char of text) { + if(char == '>' && tagStarted) { + return tag + } + else if(char === '<') { + if(tagStarted){ + tag = "" + } else { + tagStarted = true + } + } + else if(char === " " && tagStarted) { + return undefined + } + else if(tagStarted) { + tag = tag + char + } + } + return undefined +} + + + +module.exports = { findTag } \ No newline at end of file