I have nuu idea how to continue, please someone help me forward in this!
/ Sincerely, Wizibon
I have nuu idea how to continue, please someone help me forward in this!
/ Sincerely, Wizibon
Thus is like 1% of my code
// Kattgenetiska egenskaper
const _cats = [
{ name: 'Cat 1', color: 'black', pattern: 'solid' },
{ name: 'Cat 2', color: 'white', pattern: 'solid' },
{ name: 'Cat 3', color: 'black', pattern: 'striped' },
{ name: 'Cat 4', color: 'white', pattern: 'striped' }
];
// Rendera katterna i HTML
const catContainer = document.getElementById('_cats');
_cats.forEach(cat => {
const catDiv = document.createElement('div');
catDiv.classList.add('cat');
catDiv.innerText = `${cat.name} (${cat.color}, ${cat.pattern})`;
catDiv.dataset.color = cat.color;
catDiv.dataset.pattern = cat.pattern;
catDiv.onclick = selectCat;
catContainer.appendChild(catDiv);
});
let selectedCats = [];
// Hantera kattval
function selectCat(event) {
const selectedCat = event.currentTarget;
selectedCats.push({
color: selectedCat.dataset.color,
pattern: selectedCat.dataset.pattern
});
if (selectedCats.length === 2) {
showResult();
selectedCats = [];
}
}
// Visa resultatet av kattkorsningen
function showResult() {
const [cat1, cat2] = selectedCats;
const _resultColor = (cat1.color === cat2.color) ? cat1.color : 'mixed';
const _resultPattern = (cat1.pattern === cat2.pattern) ? cat1.pattern : 'mixed';
const _resultDiv = document.getElementById('_result');
_resultDiv.innerText = `Kattungens egenskaper: Färg - ${_resultColor}, Mönster - ${_resultPattern}`;
}
Can some1 please explain HEREDOC for me?
<span id="''"></span>
Hi there!
Please talk to us about your code. Tell us what do you want.
I want to come to the point where I can actually begin with eval()
Elaborate more about eval()
. I didn’t found a function eval()
in your code
It might be helpful to put all your code onto Codepen and then link to the page here so we can see what you are trying to do.
eval() is the strongest security method in the world
it’s absolutely not, using eval
is a security risk
xD Nuu. That is a forque excuse. Security has its own measurments. When something is really secury it will be listed as insecure.
that doesn’t make sense at all
You eventually come to the part as adding eval(), and as a coding tip I can say that the better your JavaScript looks like the better the HTML will be formatted.
not really? production code is often an unreadable minified mess and it doesn’t have any effect on the html
properly formatted code us easier to read
Here is my codepen.io: My little JS-game
To make a production suite you only need to place the JS files in the root folder
So, I uploaded the content to codepen. And wonder now how to continue.
Please talk about what you want for code to do and how you are stuck
I have no idea how to continue. I guess stagger the span or so-called div elements up would do. But then up next, no idea()
Please talk about what you want your code to do and how you are stuck accomplishing that