i need help regarding silly story generator. If i could get its completed solution it’d be reaaly thankful.
thank you
i need help regarding silly story generator. If i could get its completed solution it’d be reaaly thankful.
thank you
Hello Rajesh
hope that everything going fine with you
could you please send the code that you has issue with
have a nice day
@Rajesh_Sharma yes, please show us your code so far, and we’ll see if we can give you some tips.
Of course, if you are really stuck and would rather just be given the solution, I can do that too
Sir , I am really thankful to you that you responded, but now I was able to crack the code and completed the silly story generator. Thanks for the help.
you welcome and weldone congratulations
have a nice day and have fun
If you could please explain this part it’d be really helpful;
newStory = newStory.replace(':insertx:',xItem);
newStory = newStory.replace(':insertx:',xItem);
newStory = newStory.replace(':inserty:',yItem);
newStory = newStory.replace(':insertz:',zItem);
in this section why are we using ':insertx:' instead of ':insertX:'
also why we have to replace :insertx: two times, unlike others
i thought you was talking about the silly story in the html section i am still learning so i did not reac to the js yet so i will call mr chris so he can help you much better
@chrisdavidmills hello chris hope you have time to help Rajesh
have a nice day for both of you
I’m all cleared up with html, need little help with js. Thanks for calling him.
well done i will try to catch you
have a nice day
@Rajesh_Sharma hi!
So we need to include the newStory = newStory.replace(':insertx:',xItem);
line twice, because replace()
only replaces the first instance of a string, when you use it with a string, and we have two instances of :insertx:
to replace. You could use a regular expression to replace all the instances at once, but I’ve not included them here because they are more complicated.
And you also ask “in this section why are we using ‘:insertx:’ instead of ‘:insertX:’”. No particular reason for this — this is just the string placeholder I chose to be replaced.
Greetings sir
I need help with this code , its of the loops in code of the js tutorial, it is of the assesment where we have to build a countdown:
let i = 10;
while(i >= 0) {
let para = document.createElement(‘p’);
if(i === 10) {
para.textContent = 'Countdown ’ + i;
} else if(i === 0) {
para.textContent = ‘Blast off!’;
} else {
para.textContent = i;
}
output.appendChild(para);
i–;
Is specifying i=10 enough for making the countdown to stop at 10?
How have we added iteration to the code, so that it proceeds one by one?
Thank you
@Rajesh_Sharma After looking at this for a bit, I think you were just missing the last closing curly brace of the while
statement.
My modification of your code looks like this:
let output = document.querySelector('.output');
output.innerHTML = '';
let i = 10;
while(i >= 0) {
let para = document.createElement(‘p’);
if(i === 10) {
para.textContent = 'Countdown ’ + i;
} else if(i === 0) {
para.textContent = ‘Blast off!’;
} else {
para.textContent = i;
i–;
output.appendChild(para);
}
Ahhgg…that’s embarrasin, again thanks for the reply
Plus can you please give me some tips for learning js…it’s kinda hard.
Ahhgg…that’s embarrasin, again thanks for the reply
Don’t be embarrassed — making annoying simple mistakes like this is just part of programming. We all do it sometimes
In terms of learning JS, yes, it is hard when you first start. When I was first learning, I found that a combination of a longer form tutorial like the MDN ones, and shorter form tutorial with lots of quick tests to do was useful. For example, the https://www.codecademy.com/ JS lessons, or https://learnjavascript.online/
Essentially, you just need to keep practising the syntax until it starts to feel natural.
Try writing yourself a list of small apps to try and build, like:
Ask your friends or family what app they’d like you to try and build.