Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
//I need to do this with for
var name = ["Jhon", "Anne", "Ewreck", "Nine"];
for( var i = 0 ; i < name.length ; i++ ){
name[i].push(name[i].toUpperCase());
console.log(name[i]);
}
Try this
let name = ["Jhon", "Anne", "Ewreck", "Nine"];
let nameUpper = name.map( x => x.toUpperCase() )
console.log(nameUpper);
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
Having this json https://apimeta.paz.cl/
How can I filter it to create a new json when I just have objects where created_time property value is grater than 1600000?
I'm trying with this but it's not working as expected so far...
var data = JSON.parse(myjson)
var newjson = [];
data.forEach(function (entry, i) {
entry.forEach(function (changes, i) {
changes.forEach(function (changes, i) {
if (item.value.created_time >= 16000){
newjson.push(entry);
}
});
});
});
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
hello i'm work for question system i want to add many answers in a one question in a one value
html
<input id="an" placeholder="test" type="text"/><a id="wo" style="display:none;">done test</a><button id="bt">Submit</button>
javascript
const an = document.getElementById("an");
const bt = document.getElementById("bt");
bt.addEventListener("click", () => {
if (an.value.toLowerCase() === "test") { // I want create many value in here.
bt.style.display = "none";
an.style.display = "none";
document.getElementById("wo").style.display = "initial";
} else {
bt.innerText = "Wrong!"
bt.style.background = "red";
}
});
I hope this answer is what you are looking for:
You can make an array with your answers, and then check to see if the given answer is inside the array.
const array = ['test', 'test2', 'test3'];
if (array.includes(an.value.toLowerCase() ) )
...
Something else, you are missing a semicolon in your else { ... }.
bt.innerText = "Wrong!";
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
im making a timetable that when opened gives me the zoom links to my classes and tells me what classes i have in the day.
function myFunction() {
var d = new Date();
var n = d.getDay()
document.getElementById("demo").innerHTML = n;
if (n == 1) {
document.writeln("Monday")
document.writeln("you have 2 classes today X and Y and the zoom links are: ...);
}
Don't use document.write, but append elements to some wrapper:
(function () {
var wrapper = document.getElementById('wrapper');
var links = {
'http://example.com': 'Example1',
'https://example.com': 'Example2'
};
for (link in links) {
tag = document.createElement('a');
tag.setAttribute('href', link);
tag.innerText = links[link];
wrapper.appendChild(tag);
}
})();
<div id="wrapper"></div>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How do I make a 5 second delay in following code before moving to the next input element:
var inputs = document.getElementsByClassName('_aj7');
for(var i = 0; i < inputs.length; i++) {
inputs[i].click();
}
If you want to introduce a delay between actions, you need to use something like setTimeout. For example:
function f() {
inputs[i].click();
if (++i < inputs.length) {
setTimeout(f, 5000);
}
}
var inputs = document.getElementsByClassName('_aj7');
var i = 0;
if (i < inputs.length) {
f();
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to make a sidebar that dynamically create content from an object result in javascript
Object { Chemistry: Array[3], Maths: Array[1], Physics: Array[2] }
And also there are some element in Array above
I know this isn't the best way to do it, but this is an idea on how to make it:
var obj = {'Chemistry':['Chemistry1','Chemistry2','Chemistry3'],'Maths':['Maths1'],'Physics':['Physics1','Physics2']};
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function ulCreator(obj){
var menu = document.createElement("UL");
for (var key in obj) {
var node = document.createElement("LI");
var textnode = document.createTextNode(isNumber(key) ? obj[key] : key);
node.appendChild(textnode);
if(Array.isArray(obj[key])){
node.appendChild(ulCreator(obj[key]));
}
menu.appendChild(node);
}
return menu;
}
document.getElementById("main").appendChild(ulCreator(obj));
<div id="main">
</div>