I am completely stuck

#83

So the inner Y loop runs to completion before the second iteration of the X loop begins… makes sense.

Thanks CurtGreen, you’re a super star!

1 Like

#84

Dynamic List Objects I am completely stuck!

Hello All, when I attempt to write code for this exercise that Ivan lectured on, I am running into several errors:

  1. My open field list is a row instead of column.
  2. When I try to append to the list, it does not add to the list. Below is the output on my browser; along with my code. Am I missing something? I have been spending hours on this Googling, You Tubing and no “dice”:disappointed:

image

Dynamic List Objects

My favorite fruits

Add fruit
  <script>

    //var fruits = ["Apple", "Orange", "Banana","Pineapple"];
    var fruits=[{name:"Apple", color:"Green", weight:10},
    {name:"Orange", color:"Orange", weight:13},
    {name:"Banana", color:"Yellow", weight:20}];
    function redrawList(){
      var list =$("#fruitList");
      list.html("");

      $.each(fruits, function(index,value){
        console.log(value);

        $("<li>").text(value.name+","+value.color+","+value.weight).appendTo(list);
      });
    }

    redrawList();
    $("#addFruitButton").click(function(){
      var fruitName=$("#fruitNameInput").val();
      var fruitWeight=$("#fruitWeightInput").val();
      var fruitColor=$("#fruitColorInput").val();

      var fruitObject = {name:fruitName, color:fruitColor, fruit:parseInt(fruitWeight)};
        fruits.push(fruitText);
        console.log(fruits);

        redrawList();
      });

  </script>
</body>
1 Like

#85

Looking at your code you push fruits.push(fruitText); but you never make a variable by that name. Try changing that to fruits.push(fruitObject); that you created.

1 Like

#86

Lesson Learned…I solved the issue, lol, after I took a break and had lunch, I realized that the code, "var fruitObject = {name:fruitName, color:fruitColor, fruit:parseInt(fruitWeight)};
fruits.push(fruitText);
console.log(fruits);
needed to have the “fruits.push(fruitText)”; to "fruits.push(fruitObject); …now I know I missed this from Ivan’s lecture/demo initially. I am glad I went through this again.

Now the only thing I am still having an issue with is the output on my browser. I still get a row instead of a column with the blank fields and the button. Any ideas?

image

1 Like

#87

Ugh! LOL, umm yea, I had to walk away from the computer to take a break, eat something, and go back to the drawing board to re-review Ivan’s demo and figured that out too.

Thank-You for your feedback I really appreciated it.

Stephen Arias

1 Like

#88

Okay, this is driving me absolutely nuts, I have tried everything and nothing works.
I know how html works and everything, and this should be a piece of cake, yet it refuses to work.
All I’m trying to do is display an image on my website, should be easy, right?!
Here is everything summarized in one screenshot:

Why is it not displaying on my website?
I double checked the file path and file extension, even tried hotlinking the W3School’s image from their tutorial and it won’t work in my case…
Console gives me “Failed to load resource: net::ERR_FILE_NOT_FOUND”
Thanks

EDIT: I literally tried the exact same thing on my laptop and it worked there, then I went back to my desktop, tried again and all of a sudden it worked. Like, what was going on there? Love how such simple tasks can mess with your mind. xD

1 Like

#89

One of the banes of web development is ‘Browser Caching’.
For example, you’re working on a web page, you deploy it, and it’s not quite right; you amend it, then re-deploy but can’t see any of the changes you just made.
The browser has cached the old version, or is holding on to old versions of images, css, js, etc.

In Chrome, you can forcibly refresh a page’s web content by pressing Ctrl-F5 (other browsers have this feature, not sure if they all work using Ctrl-F5).
Usually this is enough to force the browser re-load the page and all resources.
(I say ‘usually’ because with some javascript frameworks - looking at you, AngularJS - this is still not enough, and you have to go into the browser settings and actually clear cached data).

It’s a bit of a pain, but hey: that’s web development for ya.

1 Like

#91

Hello dear @ivan and community,

until now the course was very easy. Currently I’m in the " Asynchronous Programming - Reading Assignment" chapter at the “JavaScript” section.

I have read the assignment and the further links. I tried to download this Node-Fibers on https://github.com/laverdet/node-fibers/ and put it in the project folder in NetBeans. Then, I tried to use the Fibers library, and make requests to the web as mentioned in the links from you @ivan. Nothing works. Errors over errors. This section and the education of it is less qualitative as before.

On https://www.discovermeteor.com/blog/understanding-sync-async-javascript-node/ there are no HTML, BODY, SCRIPT, … tags - only the code. I’m asking me: “Where to enter it?”

The same on https://strongloop.com/strongblog/node-js-callback-hell-promises-generators/ I can’t use “promises” because my IDE NetBeans don’t know promises.

On https://www.promisejs.org/ when I use:

var jQueryPromise = $.ajax('/data.json');
var realPromise = Promise.resolve(jQueryPromise);
//now just use `realPromise` however you like.

Error over errors.

Installing https://github.com/laverdet/node-fibers/ is only described via console on Linux system. How to use this library in an IDE like NetBeans?

Using the “Future Sub-library”? How? Never explained before.
When I copy this code and trying to execute:

Error over errors.

This chapter about sync and async is absolutely aside of the norm of the usual quality of the course, IMHO.

Kind regards
OtenMoten :space_invader:

:red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle::red_circle:

EDIT: L00000000000000L - I raged above, I didn’t knew anything about @ivan’s NodeJS software which he’d introduced afterwards the reading assignment.

This is the reason why the code in my NetBeans IDE didn’t work. Once, the NodeJS software is installed and the Fibers-module on top, all errors are solved and now I’m able to execute JavaScript code without the NetBeans IDE.

So, don’t rage like me at this point. Just look the following videos and everything will be explained what you need to know.

@ivan maybe you add a note that this case will be avoided.

0 Likes

Course Feedback
#92

Hello @Baiko,

I saw the Brave icon. Maybe it’s a Brave-related problem.
Image if Brave is your native system browser, that Brave has much higher security police than Chrome or Internet Explorer / Edge.

0 Likes

#93

After many hours, I’ve decided to ask for some programming help (fundamental questions and Chessboard (JS))

Is the only difference between document.write and console.log is you use one for console work and the other for html?

I’ve been watching some tutorials and they’re able to run console.log programs right on a program. I’ve been coding with Atom (as suggested) and either running it as an html, or copying and pasting the code and changing document.write to console.log. This is frustrating and seems like a waste of time. Is there an easier way?

Lastly, my chessboard code has been a complete failure:

"

I squad so hard.

This be my failed code

  <script>

  var size = 8
  var board = " ";

  for (var y = 0; y < size; y++) {

  for (var x = 0; x < size; x++) {

    if ((x+y)%2 == 0)
      board += " ";
      else
        board += "#";
    }

 }
      document.write(board);

  </script>
"

"It gives me this:

This be my failed code

# # ## # # # # # # ## # # # # # # ## # # # # # # ## # #

I scrolled through the answers and got this from a tutorial, and it still doesn’t work.
I can’t get it to go to the next line.

Beyond that, although I understand the other exercises, I fundamentally don’t understand how the x/y axis stuff is working in the chessboard exercise although parts of the exercise seems fairly intuitive (substituting variables to make the chessboard size flexible, for example).

Any help is deeply appreciated!



0 Likes

#94

I’m getting a syntax error
/*
Implements EIP20 token standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
.*/

pragma solidity ^0.4.21;

import “./EIP20Interface.sol”;

contract ADU is EIP20Interface {

uint256 constant private MAX_UINT256 = 2**256 - 1;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name;                   //fancy name: eg Simon Bucks
uint8 public decimals;                //How many decimals to show.
string public symbol;                 //An identifier: eg SBX

function ADU(
    uint256 _initialAmount,
    string _tokenName,
    uint8 _decimalUnits,
    string _tokenSymbol
) public {
    balances[msg.sender] = _initialAmount;               // Give the creator all initial tokens
    totalSupply = _initialAmount;                        // Update total supply
    name = _tokenName;                                   // Set the name for display purposes
    decimals = _decimalUnits;                            // Amount of decimals for display purposes
    symbol = _tokenSymbol;                               // Set the symbol for display purposes
}

function transfer(address _to, uint256 _value) public returns (bool success) {
    require(balances[msg.sender] >= _value);
    balances[msg.sender] -= _value;
    balances[_to] += _value;
    emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
    return true;
}

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
    uint256 allowance = allowed[_from][msg.sender];
    require(balances[_from] >= _value && allowance >= _value);
    balances[_to] += _value;
    balances[_from] -= _value;
    if (allowance < MAX_UINT256) {
        allowed[_from][msg.sender] -= _value;
    }
    emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
    return true;
}

function balanceOf(address _owner) public view returns (uint256 balance) {
    return balances[_owner];
}

function approve(address _spender, uint256 _value) public returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
    return true;
}

function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
    return allowed[_owner][_spender];
}

}

0 Likes

#95

Hi @Adu

I tried to copy and past your contract but i had an issue with the double quote which was not correct.

import “./EIP20Interface.sol”;

I wrote the double quote manually, selected this compiler on remix version:0.4.21+commit.dfe3193c.Emscripten.clang
and copy the EIP20Interface.sol in the same folder and everything works.

what is your syntax error ?
Edit: typo

0 Likes

#96

Hi @ProfessorHODL
Your code is correct you just miss a way to go to the next line.
Console.log is used for debug so you will your output in the console, and document.write in the document (so your page).
I will recommend you to add to your board a character to return to the next line when you have finish to print a line.
If you use document.write <br> will do the job it’s the line break element.
If you use console.log add “\n” to your board.
Send me a message if you are still Stuck but i tried on my side and it works.
if you want to display console log on the document you can look at this post witch is a good explanation:

1 Like

#97

Thank you for your help, l really appreciate it.

0 Likes

#98

Hi Ivan (or whoever may know this answer): I am currently working my way through the course, I got to the section on Structs and Classes, I am following the code examples and by typing the examples into CodeBlocks so that I can better retain what I am learning (and also try breaking the code to see what happens). I came to the section where it is talking about initializing the struct:

I have circled the place that is the concern for me. After repeated attempts to mimic this type of initialization on my Code Blocks setup (as it has been set up for taking the course this far) I could not make it work. I finally randomly tried putting an ‘=’ operator in the place where the circle is… and that worked. It says in the line above that this type of initialization can be done in C++11:
However, I don’t see anyway to upgrade my CodeBlocks IDE to C++11. This would be helpful to have this pointed out somehow. I have taken a Udemy course before on C++ and the instructor was careful to make sure that his examples were either in conformity with C++98? (I think that is the ‘level’ of C++ that he was using at one point in his beginner level course for C++) I was fortunate to have remembered that because I went to my Eclipse IDE that I had configured for that Udemy course and found that I got the same error messages in the compiler when I tried building the code there as I did in Code Blocks. This is not a negative on your course, I am just bringing this to your attention in the event that other noobs to C++ (such as myself) don’t get hung up on this (I trust myself little enough as it is to enter syntax and punctuation carefully… having an issue like this come up started to make me think I was going crazy (more so than I already am)).

So, after all that, is anyone aware of the settings to adjust in Code Blocks to make it compliant with C++11?

0 Likes