Need Explanation on this code

Need Explanation on this code
0

#1

Please help me by explaining every single thing in the functions below, including the .

function execCmd(command)
		{
		makeTextBold.document.execCommand(command, false, null);
		}
		
function exeCommandWithArg(command, arg)
		{
		makeTextBold.document.execCommand(command, false, arg);
		}

#2

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://freecodecamp.org.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:


#3

This is the entire page code

<!DOCTYPE html>
<html>
<head>
<script src="https://use.fontawesome.com/aac5c45839.js"></script>	
</head>
<body onload="enableEditMode()">

	<button onclick="execCmd('bold');"><i class="fa fa-bold">B</i></button>
	<button onclick="execCmd('italic');"><i class="fa fa-bold">i</i></button>
	<button onclick="execCmd('strikeThrough');"><i class="fa fa-bold">s</i></button>
	<button onclick="execCmd('justifyLeft');"><i class="fa fa-align-left">l</i></button>
	<button onclick="execCmd('justifyRight');"><i class="fa fa-bold">r</i></button>
	<button onclick="execCmd('justifyCenter');"><i class="fa fa-bold">c</i></button>
	<button onclick="execCmd('justifyFull');"><i class="fa fa-bold">f</i></button>
	<button onclick="execCmd('subscript');"><i class="fa fa-bold">s</i></button>
	<button onclick="execCmd('superscript');"><i class="fa fa-bold">s</i></button>
	<button onclick="execCmd('underline');"><i class="fa fa-bold">u</i></button>
	<button onclick="execCmd('insertHorizontalRule');"><i class="fa fa-bold">HR</i></button>
	<button onclick="execCmd();"><i class="fa fa-bold">Toggle Edit</i></button>
	<button onclick="exeCommandWithArg('insertImage', prompt('Enter the image url', ''));"><i class="fa fa-bold">image</i></button>
	<button onclick="exeCommandWithArg('createLink',prompt('Enter a URL','http://'));"><i class="fa fa-bold">p</i></button><br />
	
	<iframe name="makeTextBold" style="width: 500px; height: 250px;" ></iframe>
	<script type="text/javascript">
	
		function enableEditMode()
		{
		makeTextBold.document.designMode = "on";
		}
		
		function execCmd(command)
		{
		makeTextBold.document.execCommand(command, false, null);
		}
		
		function exeCommandWithArg(command, arg)
		{
		makeTextBold.document.execCommand(command, false, arg);
		}
	</script>
</body>
</html>

#4


#5

“At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off.” -


FCC will help further your knowledge and will help you in the long run. Even if you know what it means you wont be able to right a similar application.

makeTextBold, document.

It is a basic a text editor if you copy and paste it into pen of the code. They are changing something in the iframe/ where the text is located when they run it.


<body onload="enableEditMode()">

function enableEditMode()
		{
		makeTextBold.document.designMode = "on";
		}