These are chat archives for FreeCodeCamp/HelpFrontEnd

26th
Oct 2018
Eric Weiss
@eweiss17
Oct 26 2018 12:39
@BrianWilliams28 if you are used to using jquery, there is a jquery to base js converter
Fernando L. Estuesta
@champolot
Oct 26 2018 12:56
Is there any one here could explain why I get an error on this code
Daniel
@dbsimeonov
Oct 26 2018 12:56
Send it and we will try to help you
Fernando L. Estuesta
@champolot
Oct 26 2018 12:57
UI.prototype.showAlert=function(message,class name)
It says classname is not declared but it's value is never read
Eric Weiss
@eweiss17
Oct 26 2018 12:57
can u give the relevant code snippets
Fernando L. Estuesta
@champolot
Oct 26 2018 12:57
Sorry for the typo on my code. That's className
BrianWilliams28
@BrianWilliams28
Oct 26 2018 13:03
@br3ntor yeah but I want each LI to have different content xD
Fernando L. Estuesta
@champolot
Oct 26 2018 13:03

heres the full code

function Book(title, author, isbn) {
this.title = title;
this.author = author;
this.isbn = isbn;
}

function UI() {}

UI.prototype.addBookToList = function(book) {
const list = document.getElementById('book-list');
const row = document.createElement('tr');
row.innerHTML = <td>${book.title}</td> <td>${book.author}</td> <td>${book.isbn}</td> <td><a href="#" class="delete">X </a></td>;
list.appendChild(row);
};

UI.prototype.showAlert = function(message, className) {};

UI.prototype.clearFields = function() {
document.getElementById('title').value = '';
document.getElementById('author').value = '';
document.getElementById('isbn').value = '';
};

document.getElementById('book-form').addEventListener('submit', function(e) {
const title = document.getElementById('title').value,
author = document.getElementById('author').value,
isbn = document.getElementById('isbn').value;

const book = new Book(title, author, isbn);

const ui = new UI();

if (title === '' || author === '' || isbn === '') {
ui.showAlert('Please fill all', 'error');
} else {
ui.addBookToList(book);
ui.clearFields();
}

e.preventDefault();
});

xDDD
Daniel
@dbsimeonov
Oct 26 2018 13:10
What error gives you, className not defined? Did you try to register it and writing some output in the function instead being empty?
Im not expert with prototype functions but never seen that approach :D
Fernando L. Estuesta
@champolot
Oct 26 2018 13:12
any thing that is inside the function
Markus Kiili
@Masd925
Oct 26 2018 13:15
@champolot You have commas at the ends of lines there const title = document.getElementById('title').value,. Should they be semicolons?
Daniel
@dbsimeonov
Oct 26 2018 13:16
I think that was a way to assign multiple variables like he did ?
Markus Kiili
@Masd925
Oct 26 2018 13:17
oh yes, you are right. Missed the const there.
Fernando L. Estuesta
@champolot
Oct 26 2018 13:20
it was actually working
Dhaval Vira
@dhavalveera
Oct 26 2018 14:28
I'm facing one problem in HTML, CSS
that I can't add Background Image to HTML file with /photos/xyz.jpg that need complete file url, like file:///C:/Users/Name%20Name%20Name/Desktop/Coursera%20Learning/Portfolio%20New%201/images/iPhone.jpg
why ?
please help me out
Eric Weiss
@eweiss17
Oct 26 2018 15:28
are you developing locally?
Dany Din
@danydin
Oct 26 2018 16:27
hey someone is here
Christopher McCormack
@cmccormack
Oct 26 2018 16:31
@danydin who is it?
Dany Din
@danydin
Oct 26 2018 16:34
when i use the stringify and the parse im confused a bit @cmccormack
Christopher McCormack
@cmccormack
Oct 26 2018 16:35
@danydin what's your confusion?
Dany Din
@danydin
Oct 26 2018 16:36
like when i make a call and i get the data
to manipualte it i need to parse it first
do i need to stringify it again afterwards?
hensn5250
@hensn5250
Oct 26 2018 16:40
@danydin the data can be manipulated when in JSON form, so if it is in JSON form no need to Stringify it.

"A common use of JSON is to exchange data to/from a web server.

When receiving data from a web server, the data is always a string.

Parse the data with JSON.parse(), and the data becomes a JavaScript object."

Dany Din
@danydin
Oct 26 2018 16:58
@hensn5250 thanks why i see sometimes variables without the var
hensn5250
@hensn5250
Oct 26 2018 17:28
No prob.
In JavaScript undeclared variables are global by default.
"If you assign a value to a variable that has not been declared, it will automatically become a GLOBAL variable."
JavaScript Scope
Dany Din
@danydin
Oct 26 2018 17:32
@hensn5250 you're amazing
hensn5250
@hensn5250
Oct 26 2018 17:36
JSON is JavaScript Object Notation , its just a ** Stringified JS object --> ' { key: value}'
Aditya
@ezioda004
Oct 26 2018 17:37
Its a stringified JS object*
hensn5250
@hensn5250
Oct 26 2018 17:37
^^ right
Dany Din
@danydin
Oct 26 2018 20:41
oh ok thanks and what-when we use the stringify method? @hensn5250 @ezioda004
Aditya
@ezioda004
Oct 26 2018 20:42
@danydin When you're sending data from frontend to server and vice versa.
Dany Din
@danydin
Oct 26 2018 20:45
thanks! why fcc chat is dead does everybody gave up on programming or it just that they all too advanced for this place :P @ezioda004
Aditya
@ezioda004
Oct 26 2018 20:47
@danydin Mainly because gitter chats were removed from fcc challenges. Usually Javascript and Help rooms are active.
Christopher McCormack
@cmccormack
Oct 26 2018 20:47
Yeah I think Gitter link was removed from the entire cirriculum site
used to be in Settings after it was taken out of the challenges but I don't see it anymore
Dany Din
@danydin
Oct 26 2018 20:51
ahh i see... i remember it from long ago wired that they took it off it's pretty helpful and unique
and was pretty popular as well a while ago
Brad
@bradtaniguchi
Oct 26 2018 20:53
I think FCC wanted to focus on the forums as the goto source. The thing about the chat rooms (especially the general room) was it was off topic more often than not
Dany Din
@danydin
Oct 26 2018 20:55
well maybe the general the rest were pretty mch straight to the point
Brad
@bradtaniguchi
Oct 26 2018 20:58
Yea, I think it was quincy's decision. Oh well
Dany Din
@danydin
Oct 26 2018 20:59
wired they took it off i dont get what stands behind this decision
Brad
@bradtaniguchi
Oct 26 2018 21:02
There was a huge mess in the general room a few weeks or so before they closed it, a bunch of users got banned/left for some discord channel. After-which the room was more quiet and a little after that they announced they would remove the general room all together. This was all way after they removed the link to the chat tho
Christopher McCormack
@cmccormack
Oct 26 2018 21:02
The JavaScript room was a non-stop stream of the same JavaScript questions most of the time. Many of us had canned responses to a lot of them