Tutorials related chat. For other discussions please join https://gitter.im/codebar/chat
KimberleyCook on gh-pages
feat(html, lesson2): added chil… Merge pull request #483 from al… (compare)
dependabot[bot] on bundler
dependabot[bot] on bundler
Bump addressable from 2.5.2 to … (compare)
richardwestenra on gh-pages
Corrected minor spelling and gr… Merge pull request #481 from pe… (compare)
scss
can be verbose like anything. It's just a tool and is often recommended because of it's compiled nature vs. css
. You can still use it as if it were css
. There are plenty other reasons to use it and solutions to work around it being 'verbose'. Happy to chat at pub or in a codebar session. Please bring examples and I'll bring myself and try help :- )
Hi: I'm practising exercises from Head First Javascript Programming (p.101).
I write the code in the book in the console and it gives me an error: points is not defined. It's not necessary to define a variable points for the parameters, right? Thanks in advance.
var avatar = "generic";
var skill = 1.0;
var pointsPerLevel = 1000;
var userPoints = 2008;
function getAvatar(points){
var level = points / pointsPerLevel;
if (level == 1) {
return "Teddy bear";
} else if (level == 1) {
return "Cat";
} else if (level >= 2) {
return "Gorilla";
}
};
function updatePoints(bonus, newPoints) {
var i = 0;
while(i<points){
newPoints = newPoints + skill * bonus;
i = i + 1;
}
return newPoints + userPoints;
}
userPoints = updatePoints(2,100);
avatar = getAvatar(2112);
while (i < points)
points
doesn't appear to be defined in the scope of updatePoints
I mean.
Hi everyone,
I'm practising Javascript with exercises from two books. They explain not to use global variables but then in the examples, they use them very often. So I'd like to rewrite this example from Javascript Head First, so that it's all done with locals. But my version is not completely right...So I'd appreciate your comments. Thanks in advance.
The code from the book:
var avatar = "generic";
var skill = 1.0;
var pointsPerLevel = 1000;
var userPoints = 2008;
function getAvatar(points){
var level = points / pointsPerLevel;
if (level == 1) {
return "Teddy bear";
} else if (level == 1) {
return "Cat";
} else if (level >= 2) {
return "Gorilla";
}
};
function updatePoints(bonus, newPoints) {
var i = 0;
while(i<bonus){
newPoints = newPoints + skill * bonus;
i = i + 1;
}
return newPoints + userPoints;
}
userPoints = updatePoints(2,100);
avatar = getAvatar(2112);
My version with locals - but gives me undefined...
function getAvatar(points){
var pointsPerLevel = 1000;
var level = points / pointsPerLevel;
if (level == 1) {
return "Teddy bear";
} else if (level == 1) {
return "Cat";
} else if (level >= 2) {
return "Gorilla";
}
};
function updatePoints(bonus, newPoints) {
var i = 0;
var skill = 1.0;
var userPoints = 2008;
while(i<bonus){
newPoints = newPoints + skill * bonus;
i = i + 1;
}
return newPoints + userPoints;
}
function init(){
userPoints = updatePoints(2,100);
var avatar = getAvatar(2112);}
level == 1
. you should always use ===
not ==
in the book,
there is the default value of 'avatar' so it seems to work well even though it is weird there is the same condition twice,
but in your version,
the return value of getAvatar() hasn’t the default one.
So if level is not equal to 1,2 or greater than 2, getAvatar() will return undefined…
you could code like following...
getAvatar(){
if(){..}
else if() {..}
return ‘generic’;
}
That is just my guess, so it might be wrong...
Hi: I'd like to know how to create a .gitignore file from the command line to exclude .idea related files. I don't know what do I need to exclude.
Or if this is just a txt.file.
I have this:
'code'
Carolinas-MBP:first_git_project carolina$ git add .
Carolinas-MBP:first_git_project carolina$ git commit -m "Initial commit"
[master (root-commit) 19c3842] Initial commit
9 files changed, 394 insertions(+)
create mode 100644 .idea/.name
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/copyright/profiles_settings.xml
create mode 100644 .idea/first_git_project.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 .idea/workspace.xml
create mode 100644 first_file.html
Carolinas-MBP:first_git_project carolina$ .idea/
-bash: .idea/: is a directory
Carolinas-MBP:first_git_project carolina$
'code'
I know that inside the .gitignore file I can add this:
.idea/workspace.xml
.idea/modules.xml
Thanks!
echo .idea >> .gitignore
will add ".idea" to the ignore
echo ".idea" >> .gitignore
>
because that will overwrite the file rather than append to it
Shall I ignore the .gitignore "untracked files" and the "changes not staged for commit"? Here's the console.
"code"
Carolinas-MBP:first_git_project carolina$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .idea/misc.xml
modified: .idea/workspace.xml
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
Carolinas-MBP:first_git_project carolina$
"code"
Thanks.