Help me with Javascript

I’m learning Javascript these days,using The book called Dom programming art
Here is the problem,I want to use JS to create content,but nothing happen when I open my html document. What’s the problem? Thank you
Here is the code below:

	var para=document.creatElement("p");
	var txt=document.creatTextNode("hello world");
	var testdiv=document.getElementById("testdiv");
<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8"/>
 <div id="testdiv">
  <script type="text/javascript" src="scripts/example.js"></script>

you have a typo in your code. its var para= document.createElement(“p”) not var para=document.creatElement(“p”);

You missed an “e” in document.creatElemen

Hello there I started learning javascript. I still cant figure a way to get past this challenge. If anyone can help that will be great. The question below:

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = “”;
// Your code below this line
result = “myNoun” + “myAdjective” + “myVerb” + “myAdverb”;

// Your code above this line
return result;

// Change the words here to test your function
wordBlanks(“dog”, “big”, “ran”, “quickly”);

did u try without quotes? like:
result = myNoun + myAdjective + myVerb + myAdverb;
since myNoun and others are VARIABLES
if u put something in quotes programs treat it like strings (text) so your output would be:
and not:

if u want to separate them it should go like:
result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;

1 Like

Thank you so much pal, you’re a life saver.

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

You can’t post raw html, since it does not display.

Copy this and paste in your code :

var para=document.createElement(“p”);
var txt=document.createTextNode(“hello world”);
var testdiv=document.getElementById(“testdiv”);

Or you can type :

 function myFunction() {
       var para=document.createElement("p");
       var txt=document.createTextNode("hello world");
      var testdiv=document.getElementById("testdiv");


This is very simple

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.