solved Task 3
This commit is contained in:
+28
@@ -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 }
|
||||
Reference in New Issue
Block a user