Hi, i hope to get assesment in this case solving a conditional 1 test.
Conditionals 1 Test
Did i solve it correctly ? Pls check the following code. Thx in advance. Regards
<meta charset="utf-8"/>
<title>Conditionals: Task 1</title>
p {
color: purple;
margin: 0.5em 0;
}
* {
box-sizing: border-box;
}
<link rel="stylesheet" href="../styles.css" />
<section class="preview">
</section>
Hi there @nevertolate!
I’d be happy to have a look at your work. Can you put it in an online code editor like CodePen or Glitch so I can look at it in action?
Hi Chris,
i put it in CodePen.
https://codepen.io/elgijo124/pen/OJPGmoZ
how can i Login to your Forum without getting everytime an email ?
I put my Code underneath the initialized Response not above it, like it is written in Code. I got allways Errors when i put it Right were it should be ?! it says undefined then, so i put it after codeblock …
let season = ‘summer’;
let response;
then it worked. Is it correct or is there a other possibility in front of or above the mentioned codeblock ?
@nevertolate thanks!
So your code works as expected. We went for a single if/if else/else block in our code,which is neater and more robust:
if(season === 'summer') {
response = 'It\'s probably nice and warm where you are; enjoy the sun!';
} else if(season === 'winter') {
response = 'I hope you are not too cold. Put some warm clothes on!';
} else {
response = 'I don\'t know what the season is where you are. Hope you are well.';
}
But yours works too.
1 Like
Ah, sorry about that — there was a mistake in the code examples; I’ve now updated it in our GitHub repo and on MDN. The starting code now looks like this:
let season = 'summer';
let response;
// Add your code here
// Don't edit the code below here!
section.innerHTML = ' ';
let para1 = document.createElement('p');
para1.textContent = response;
section.appendChild(para1);
1 Like