Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
function move() {
var elem = document.getElementById("myBar");
var width = 0;
var id = setInterval(frame, 10);
function frame() {
if (width == 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
}
}
}
</script>
elem.style.width = width + '%';
line does here?
width
property will look like width: x%
where x
is the actual width
:)
aditya8349_twitter sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1225 | @marmiz |http://www.freecodecamp.org/marmiz
var num;
arr = ([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++){
if (num < arr[i][j]) {
num = arr[i][j];
}
}
}
console.log(num);
I'm trying to return the largest numbers from each of those sub-arrays. But I don't know how I can store the largest number in a variable. Anyone have an idea?
(undefined < arr[i][j])
which is false, so the num never gets set to anything
@NJM8
var num;
arr = ([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++){
num = [i][0];
if (num < arr[i][j]) {
num = arr[i][j];
}
}
}
console.log(num);
I've done something like this, but now it's returning the last number of the sub-array. How do I get it to iterate through the sub-array and a store the largest value from that sub-array?
num = arr[i][j]
then put it in an if statement that will only let it run if i
and j
are zero
@NJM8 I did just that.
var num;
arr = ([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++){
num = [i][j];
if (num = arr[0][0]) {
num = arr[i][j];
}
}
}
console.log(num);
I don't know why it is returning a 1 though. Also how do I store a variable from the sub-array doing this method, because it looks like the code thats going to return the largest number from the entire array of sub-arrays.
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++){
num = [i][j]; // I run every single loop, so I always set num to the current value
if (num = arr[0][0]) {
num = arr[i][j];
}
}
}
arr
in front of [i][j]
?
var num;
arr = ([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++){
if (i === 0 && j === 0) {
num = arr[i][j];
}
if (num < arr[i][j]) {
num = arr[i][j];
}
}
}
console.log(num);
var results = [];
var arr = [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];
for (var i = 0; i<arr.length; i++) {
var num;
for (var j = 0; j<arr[i].length; j++) {
if (j === 0) {
num = arr[i][j];
}
if (num < arr[i][j]) {
num = arr[i][j];
}
}
results.push(num);
}
console.log(results);
require('fs')
import
at this time due to I believe not being fully standardized yet
console.log(process.argv[2]);
console.log(process.argv[3]);
console.log(process.argv[4]);
node server1.js server2.js
doesnt make sense
console.log(process.argv[2]);
console.log(process.argv[3]);
console.log(process.argv[4]);
const b = require(`./${process.argv[4]}`);
b();
module.exports = function(){
console.log(x);
}
Hmm. Trying to turn an array into a list.
<ul>
${body.actions.map(action => `<li>${action}</li>`)}
</ul>
Where body.actions
is an array with one or more items. With a single item, the returned result is fine. But if more than one, than I get some extra spacing and a comma added..
• Item 1
,
• Item 2
,
• Item 3
Any one know why? This is a bit of HTML for an email message.
join(" ")
@JLuboff
<li> ${action.join('')}</li>
?
jluboff sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3748 | @moigithub |http://www.freecodecamp.org/moigithub