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!
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!
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:
<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>
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.
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?
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
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
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.
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
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.
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.
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. <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:
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).
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];
}
}
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
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:
Thank you for your help, l really appreciate it.
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:So, after all that, is anyone aware of the settings to adjust in Code Blocks to make it compliant with C++11?
Hello My Fellow Atomic Clock friends.
I am not stuck…however im sure that at sometime i will be so im taking this time to
Thank you in Advance for your future help and Support.
Looking forward to the FUTURE.
Hello, I built the HTML page - then I experimented with trying to get it up there looking like a page - copy to the tool bar or something - I did a few experiments - one of them worked - I got the page up there - it looked good - but can’t figure out how I did it.
The one that worked had a google symbol on it in the documents file.
Can you just give a step by step instruction how to get it up there.
D
Hi. Are you talking about a spesific course or are you just trying to “get it up” there in a project… Not trying to be rude, just trying to figure out how to help you.
Ivo
Hello,
Thank you for your email,
Actually, I followed the video again and I managed to get the coding to show up as a web page - so that is progress - then I managed to do the link and I got a link from the webpage to google.
The next thing is putting an image on the webpage, and I’ve come unstuck again.
I’m sure I’ll figure it out eventually but any tips would be helpful.
It’s just basically getting the html code and the pic in the same desktop folder, right, then somehow getting the pic linked into the code in the HTML.
I just keep hacking at the wall and I get there in the end.
Have a great weekend,
D
if the html file and the image file are in the same folder it’s very easy to add the image to the webpage.
Let’s say that the filename of the image is dog.png
you can show that image on the page with <img src="dog.png"/>
Let me know if that solved your issue.
If not, please post your code here and we will take a look.