Help me with Javascript

Help me with Javascript
0

#1

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:

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

#2

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


#3

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”);


#4

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:
myNounmyAdjectivemyVerbmyAdverb
and not:
dogbigranquickly

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


#5

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


#6

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.