solved Task 3
This commit is contained in:
parent
d0e69401e0
commit
c2a0fefd54
|
@ -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 }
|
Loading…
Reference in New Issue