These are chat archives for FreeCodeCamp/Help

7th
May 2019
Tamara HJ
@Tamara122
May 07 05:31
Basic Data Structures: Iterate Through the Keys of an Object with a for...in Statement
i am stuck with this
any one help
Randell Dawson
@RandellDawson
May 07 05:35
@Tamara122 Hi there. What kind of help do you need? Do you understand the task?
Tamara HJ
@Tamara122
May 07 05:35
no
?
Randell Dawson
@RandellDawson
May 07 05:38
A for..in loop allows you to iterate through an object's properties/keys, so in this case, obj which is the users object passed to the function has 4 properties ('Alan', 'Jeff', 'Sarah', and 'Ryan'
Tamara HJ
@Tamara122
May 07 05:39
okay ?
771186913
@771186913
May 07 05:39
https://github.com/vechain/thor-devkit.js 有没有给大佬 来个签名的dome
Randell Dawson
@RandellDawson
May 07 05:40
If you look at the example in the challenge, it shows you the syntax you will use, but instead of users, you will use obj.
771186913
@771186913
May 07 05:40
怎么用吗
Tamara HJ
@Tamara122
May 07 05:41
okay thx @RandellDawson
@771186913 ???
771186913
@771186913
May 07 05:42
@Tamara122 How to sign the transaction with the private key
Randell Dawson
@RandellDawson
May 07 05:42
The values of these properties are objects also which have an online property that you will need to check if it is true. If so, you will need to count it in some way so that you return the total number of these user objects which have an online property value of true.
Tamara HJ
@Tamara122
May 07 05:43
so how will the solution will look like
@771186913 thx bro
Randell Dawson
@RandellDawson
May 07 05:43
That is for you to figure out.
Give it a try and if you get stuck, post your code.
771186913
@771186913
May 07 05:45
image.png
I wrote this code and it didn't generate signatures.
@Tamara122
Tamara HJ
@Tamara122
May 07 05:50

let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};

function countOnline(obj) {
// change code below this line

// change code above this line
}

@771186913 i dont know sorry
771186913
@771186913
May 07 05:51
What do you write this for?
Randell Dawson
@RandellDawson
May 07 05:51
@Tamara122 You have not written any code yet. You need to try and implement what I suggested.
771186913
@771186913
May 07 05:51
@Tamara122
Tamara HJ
@Tamara122
May 07 05:52
@RandellDawson i dont understand i did it several times so i just reset it all
@771186913 this code for aqustion in free codecamp
Basic Data Structures: Iterate Through the Keys of an Object with a for...in Statement
Randell Dawson
@RandellDawson
May 07 05:53
Well, try again and post what you try that does not work, so I have an idea what direction you are headed.
Tamara HJ
@Tamara122
May 07 05:53
this one
okay
771186913
@771186913
May 07 05:54
@Tamara122
image.png
The purpose is to generate signatures
Thor-devkit.js, which I can't use
@Tamara122
@Tamara122
Tamara HJ
@Tamara122
May 07 05:56
i feel like i am stuck in js like i cant solve or understand any thing
i want to study js from the first again
:(
771186913
@771186913
May 07 05:57
Is it a typescript developer crazy?
@Tamara122
Tamara HJ
@Tamara122
May 07 05:57
hahaha
Randell Dawson
@RandellDawson
May 07 05:57
@Tamara122 If you were asked to do the same thing with a plain for loop, would you be able to do that? I don't know if it is the for...in part or the overall logic that is stumping you.
771186913
@771186913
May 07 05:58
哈哈
我是写PHP的
现在写js
Tamara HJ
@Tamara122
May 07 05:59
i think i am stuck with for loop all
Randell Dawson
@RandellDawson
May 07 06:01
I suggest going back through the for loop challenges in the Basic JavaScript section starting with https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-while-loops to help you remember how to iterate with for loops.
I am going to sleep now. If you need more help, I recommend clicking the Ask for Help button on the challenge and ask your questions over on the forum. Just make sure to try to write some code for the challenge first.
Tamara HJ
@Tamara122
May 07 06:05
okay thx

let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};

function countOnline(obj) {

// change code below this line
  let counter = 0;
for (let user in obj) {
    console.log(user);  // not what you think!
    if(user.online === true){
        counter ++;
    }
}
return counter;
    // change code above this line

console.log(countOnline(users));

its not working too
Magdaline Sisungo
@magdalinesisungo
May 07 15:09

Write a function named tens that, using a for loop, prints all numbers in this list [1,2,3,4,5,6,7,8,9] with each number multiplied by 10

Write a function that, using list comprehension, returns all items in this list [2,4,6,8,10,12] as squares

Write a function named sorted that combines and sorts these two lists
[9,1,4,7,3]
[5,2,6,8,0]

Write a function named range_sum that accepts a number n and returns the sum of all numbers from 1 to n.

Write a Python function named largest that accepts a list of integers and returns the largest numbers in the list. Example:
largest([1,3,6,8,2,4,5.7]) returns 8

Write a Python function named smallest that accepts a list of integers and returns the smallest number in the list. Example:
smallest([1,3,6,8,2,4,5.7]) returns 1

Write a function name my_modulus that; Using the range function and a for loop creates a dictionary that contains all the numbers between 10 and 20 with each number as the key and the remainder of its division by 3 as the value

Given this list of students students = [{'balance': 1000, 'name': 'Irene'}, {'balance': 2000, 'name': 'Pauline'}, {'balance': 3000, 'name': 'Naima'}, {'balance': 1000, 'name': 'Rose'}]
Using a for loop print “hello {name}, your balance is {balance}” for each student.

Liberty
@LibertyGTX
May 07 18:52
Hello. Where could i get some help on an issue i'm having with HTML&CSS?
Brad
@bradtaniguchi
May 07 18:53
@LibertyGTX Post your question here, or the HelpFrontEnd room, and someone will answer if they can
Tamara HJ
@Tamara122
May 07 21:33
@magdalinesisungo thx 🌸