From c2a0fefd541b953d56ef75212855054cc049102d Mon Sep 17 00:00:00 2001 From: schrom01 Date: Thu, 6 Oct 2022 10:32:23 +0200 Subject: [PATCH] solved Task 3 --- find-tag.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 find-tag.js 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