I've been studying JavaScript from a lot of sources recently to better understand it and I still have trouble for anything past basic functions and syntax which most tutorials show. I'm familiar with object oriented programming, but when trying something more "complex" it breaks down. Is there a thing trying to perform multiple conditions within a function? I can do things one at a time but it wouldn't be optimal. Just really wanna better understand vs instant solutions please. :)
"Write a JavaScript program which will display a button and ask user to enter one character and a name. Your program will then put the name inside a box which is formed by using the character entered. The following demonstrate a test run when user entered a * and a name ‘John’. "
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
width: 300px;
border: 1px solid RED;
padding: 10px;
margin: 25px;
}
</style>
<script>
var i = 0;
function nameInBorder() {
for (i < 8) {
document.write(symbol);
i++
}
document.write("<br>"
symbol + symbol) +
document.writeln(name + symbol + symbol);
for (i < 8) {
document.write(symbol);
i++
}
}
function askName() {
let name = prompt("Enter your name", "");
}
function askSymbol() {
let symbol = prompt("Type a symbol to border your name such as * or #", "");
askName();
nameInBorder();
}
</script>
</head>
<body>
<h1>Put your name in a box
<br>
<br>
<input type="button" value="Get started now!" onclick="askSymbol()">
</h1>
</body>
</html>