solved Task 3

This commit is contained in:
schrom01 2022-10-06 10:32:23 +02:00
parent d0e69401e0
commit c2a0fefd54
1 changed files with 28 additions and 0 deletions

28
find-tag.js Normal file
View File

@ -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 }