Planning to create a program that extracts the domain from an email address. How can this be done without using built-in functions like .map .filter .reduce .split .join .indexOf .findIndex .substring? Many online sources suggest using a for loop to locate "@" and "." symbols, but how do you extract the string between these two markers as the output?
For example: Input = [email protected] Output = gmail
Input = <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80f4f2e9f0ece5b2c0f9e1e8efefaee3efed">[email protected]</a>
Output = yahoo
let input = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5889c87809691a58288848c89cb868a88">[email protected]</a>"
let output = ""
let begin = ""
let end = ""
for (let i = 12; i<input.length; i++){
if(input[i] == "@"){
begin += input[i+1]
}
}
for (let j = 0; j<input.length; j++){
if(input[j] == "."){
end += input[j-1]
}
}