9th
Sep 2017
nathanl127
@nathanl127
Sep 09 2017 00:27
This message was deleted
This message was deleted
This message was deleted
aRtoo
@artoodeeto
Sep 09 2017 00:35
whats up fam!!! quick question. should i get the total of cid from this algorithm challenge entitled Exact Change
nathanl127
@nathanl127
Sep 09 2017 00:35
This message was deleted
This message was deleted
This message was deleted
This message was deleted
piteto
@piteto
Sep 09 2017 00:38
@nathanl127 to compare use == or === not =
Also, navar = 21 is scoped inside another function
nathanl127
@nathanl127
Sep 09 2017 00:38
This message was deleted
nathanl127
@nathanl127
Sep 09 2017 01:03
This message was deleted
This message was deleted
This message was deleted
korzo
@korzo
Sep 09 2017 01:08
@nathanl127 Is this free code camp challenge ?
nathanl127
@nathanl127
Sep 09 2017 01:08
This message was deleted
korzo
@korzo
Sep 09 2017 01:08
@nathanl127 what's the name
?
nathanl127
@nathanl127
Sep 09 2017 01:09
This message was deleted
This message was deleted
This message was deleted
This message was deleted
korzo
@korzo
Sep 09 2017 01:12
@nathanl127 No, that's fine :)
I was just curious what you are tiying to achieve in this code
Because you have 2 different x ( global x and x local to function scope) and it does nothing
nathanl127
@nathanl127
Sep 09 2017 01:14
This message was deleted
This message was deleted
korzo
@korzo
Sep 09 2017 01:16
@nathanl127 Those buttons with "Don't touch me" text?
nathanl127
@nathanl127
Sep 09 2017 01:19
This message was deleted
This message was deleted
This message was deleted
Abhishek Kumar Pandey
@abhishekpandeykr
Sep 09 2017 01:51
i am trying to create countdown timer, it will remove day if day is less than o
days = Math.floor(time / (1000 * 60 * 60 * 24)); hours = Math.floor((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60)); seconds = Math.floor((time % (1000 * 60)) / 1000); console.log('time', days, hours, minutes, seconds); if (days < 0) { this.message = hours + ' hours ' + minutes + ' minutes ' + seconds + ' seconds left'; return this.message; } else if (hours < 0) { this.message = minutes + ' minutes ' + seconds + ' seconds left'; return this.message; } else if(minutes < 0) { this.message = seconds + ' seconds left'; return this.message; } else { return this.message = 'done' }

Ghost
@ghost~55a04b725e0d51bd787af54c
Sep 09 2017 01:51
@abhishekpandeykr Wait, aren't you on quora?
Abhishek Kumar Pandey
@abhishekpandeykr
Sep 09 2017 01:52
 days = Math.floor(time / (1000 * 60 * 60 * 24));
hours = Math.floor((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60));
seconds = Math.floor((time % (1000 * 60)) / 1000);
console.log('time', days, hours, minutes, seconds);
if (days < 0) {
this.message = hours + ' hours ' + minutes + ' minutes ' + seconds + ' seconds left';
return this.message;
} else if (hours < 0) {
this.message = minutes + ' minutes ' + seconds + ' seconds left';
return this.message;
} else if(minutes < 0) {
this.message = seconds + ' seconds left';
return this.message;
} else {
return this.message = 'done'
}
yeah
Diego Mayer
@Chrono79
Sep 09 2017 02:09
@abhishekpandeykr unless time is negative, none of those vars will be less than 0
try with === 0
Vuyani M Ngcana
@celfInfinite
Sep 09 2017 05:57

i wrote the below program to translate a given string to pig latin, when running the function with arguments glove, algorithm and eight function produces the desired result but when arguments california and paragraphs are run with function the result is wrong. see function below:
function translatePigLatin(str) {
var vowels = ['a', 'e', 'i', 'o', 'u'];
var tmp = [];
var strArr = str.split("");
if (vowels.indexOf(strArr[0]) !== -1)
str = strArr.join("") + "way";
//console.log(str);
else {
for (var i = 0; i < strArr.length; i++)
if (vowels.indexOf(strArr[i]) === -1) {
tmp.push(strArr.shift());
}
str = strArr.join("") + tmp.join("") + "ay";
}
return str;
}

translatePigLatin("consonant");



i wrote the below program to translate a given string to pig latin, when running the function with arguments glove, algorithm and eight function produces the desired result but when arguments california and paragraphs are run with function the result is wrong. see function below:

function translatePigLatin(str) {
var vowels = ['a', 'e', 'i', 'o', 'u'];
var tmp = [];
var strArr = str.split("");
if (vowels.indexOf(strArr[0]) !== -1)
str = strArr.join("") + "way";
//console.log(str);
else {
for (var i = 0; i < strArr.length; i++)
if (vowels.indexOf(strArr[i]) === -1) {
tmp.push(strArr.shift());
}
str = strArr.join("") + tmp.join("") + "ay";
}
return str;
}

translatePigLatin("consonant");

_

Jefferson
@jeffersonnnn
Sep 09 2017 07:19
guys, can someone tell me how to return the place of an element after it has been returned from an array?
Jefferson
@jeffersonnnn
Sep 09 2017 07:50
for reference, i am at the Where do i Belong challenge and here is my code up to this point

function getIndexToIns(arr, num) {
var args = Array.prototype.slice.call(arguments);
arr.sort(function(a, b){return a - b;
});
for (i = 0; i < arr.length; i++) {
if (arr[i] >= num);
return arr[i];
} else; {

}
}

getIndexToIns([40, 60], 50);
Ogundele Olumide
@Lumexralph
Sep 09 2017 07:54
@jeffersonnnn use index i to return the position
Ogundele Olumide
@Lumexralph
Sep 09 2017 08:00
@celfInfinite it's not always a good idea to mutate an array you're looping or iterating through
@celfInfinite tmp.push(strArr.shift()); shift() removes the first element in an array, returns it and mutates the array, that might be a likely cause... still looking through
Jefferson
@jeffersonnnn
Sep 09 2017 08:06
@Lumexralph how so
Vuyani M Ngcana
@celfInfinite
Sep 09 2017 08:07
@Lumexralph i think my logic in my else statement is flawed, i might have to rethink the else statement.
Daniel Romero
@Ranacode
Sep 09 2017 08:21
Hi guys..
I have a problem with bcryptjs, is not hashing my passwords :S
Stephen James
@sjames1958gm
Sep 09 2017 09:58
@jeffersonnnn You have an extra ';' at the end of both if and else that don't belong
Fernando
@lestairon
Sep 09 2017 09:59
https://codepen.io/Lestairon/pen/ayraQg
What's wrong with my js code?
Emmanuel Akodia
@akodiaemma
Sep 09 2017 09:59
hello my dear programmer friends
Stephen James
@sjames1958gm
Sep 09 2017 10:01
@lestairon
• you haven't included jquery in your settings.
• you wont be able to use an http:// API from https:// web page
@akodiaemma greetings
Fernando
@lestairon
Sep 09 2017 10:02
@sjames1958gm Right...
Thanks
CamperBot
@camperbot
Sep 09 2017 10:02
lestairon sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8454 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Fernando
@lestairon
Sep 09 2017 10:02
Hahaha
Stephen James
@sjames1958gm
Sep 09 2017 10:02
@lestairon :+1:
Fernando
@lestairon
Sep 09 2017 10:02

I'm laughing at

you haven't included jquery in your settings.

Emmanuel Akodia
@akodiaemma
Sep 09 2017 10:03
sorry
if(!isMobile()&&compatibility.supportsHTMLVideo()){$("#video-wrapper").html('<video loop="" poster="" id="homevideo"><source src="video/presentation.mp4" type="video/mp4"><source src="video/presentation.m4v" type="video/mp4" /><source src="video/presentation.webm" type="video/webm" /><source src="video/presentation.ogv" type="video/ogg" /><source src="video/presentation.mp4" /></video>')}else{$("#video-wrapper").html('<img src="images/backgrounds/mobile-header-bg.jpg">')}
@sjames1958gm i was wondering if you if(!isMobile()&&compatibility.supportsHTMLVideo()){$("#video-wrapper").html('<video loop="" poster="" id="homevideo"><source src="video/presentation.mp4" type="video/mp4"><source src="video/presentation.m4v" type="video/mp4" /><source src="video/presentation.webm" type="video/webm" /><source src="video/presentation.ogv" type="video/ogg" /><source src="video/presentation.mp4" /></video>')}else{$("#video-wrapper").html('<img src="images/backgrounds/mobile-header-bg.jpg">')}
Fernando
@lestairon
Sep 09 2017 10:05
you wont be able to use an http:// API from https:// web page" this, what can i do?
Emmanuel Akodia
@akodiaemma
Sep 09 2017 10:11
@sjames1958gm do i save different versions of the video in the video folder
Diego Mayer
@Chrono79
Sep 09 2017 11:15
@lestairon you can use a proxy server
Fernando
@lestairon
Sep 09 2017 11:40
Codepen?
Proxy Server?
Api?
How?
Diego Mayer
@Chrono79
Sep 09 2017 11:45
basically you append https://crossorigin.me/ to the url you want to pass to the proxy
there are other similar services
Fernando
@lestairon
Sep 09 2017 11:55
Oh
I think my code is the problem
Still not working at all
Diego Mayer
@Chrono79
Sep 09 2017 12:01
Fernando
@lestairon
Sep 09 2017 12:04
horo
@wolfHoro
Sep 09 2017 12:09
function destroyer(arr) {
// 请把你的代码写在这里
var i;
var newarr;
var args = Array.from(arguments);
function deletearr(arr){
for (i=1;i<args.length-1;i++){
if(args[0].indexOf(args[i])!==-1){
continue;
}else{
return false;
}
}
return true;
}
newarr=args[0].filter(deletearr);

return newarr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Why doesn't my function work?
Diego Mayer
@Chrono79
Sep 09 2017 12:11
@wolfHoro instead of continue return a truthy value
@lestairon youyr code is not ok, I'll be back in a while
horo
@wolfHoro
Sep 09 2017 12:15
@Chrono79 I tried it, but it still doesn't work
@Chrono79 or is my code completely wrong?
Diego Mayer
@Chrono79
Sep 09 2017 12:21
@wolfHoro now that I see your code better
the argument of the function you pass as a callback to filter is every value of the array you call filter with
you don't need to use a loop (filter is already a loop on disguise itself)
args[0] is arr in your code
you could use slice to keep only the arguments that are not arr
horo
@wolfHoro
Sep 09 2017 12:28
@Chrono79 Thank you, my friend. Let me think about it
CamperBot
@camperbot
Sep 09 2017 12:28
wolfhoro sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4533 | @chrono79 |http://www.freecodecamp.com/chrono79
Fernando
@lestairon
Sep 09 2017 12:33
Hm
Still don't know whats wrong with my code, maybe it's how am i using the API
I don't know, first time using one
Diego Mayer
@Chrono79
Sep 09 2017 12:48
@lestairon
  $("#newquote").on("click", function(e) { e.preventDefault();$.getJSON("https://cors-anywhere.herokuapp.com/http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", function(data) {
console.log(data);
$("#text").html(data); }); }); use the developer tools and see what data is Ahmed raza @Raza403 Sep 09 2017 13:25 I need help in fabonacci challenge, kindly help me in finding bug https://pastebin.com/UCJd2Uv0 Diego Mayer @Chrono79 Sep 09 2017 13:37 @Raza403 read the instructions again you're finding num fibonacci numbers you have to find m (m is less than num) fibonacci numbers less than or equal to num Given a positive integer num, return the sum of all odd Fibonacci numbers that are less than or equal to num. Ahmed raza @Raza403 Sep 09 2017 13:40 @Chrono79 You mean fab number should be less than "num"? Diego Mayer @Chrono79 Sep 09 2017 13:41 let's say num is 10, then the fibonacci numbers less than or equal to 10 are 1, 1, 2, 3, 5, 8 (adding only the odd ones you'll get 10) you don't have to find 10 fibonacci numbers see the difference? Ahmed raza @Raza403 Sep 09 2017 13:45 @Chrono79 Got it boss Thanks.. CamperBot @camperbot Sep 09 2017 13:45 raza403 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 4534 | @chrono79 |http://www.freecodecamp.com/chrono79 Diego Mayer @Chrono79 Sep 09 2017 13:45 :+1: Ronique Ricketts @RoniqueRicketts Sep 09 2017 13:50 If I should build the tribute page from beta.fcc with react would I still pass the tests as beta suggested doing it Diego Mayer @Chrono79 Sep 09 2017 13:53 I guess Serhii Borovskyi @serhiicss Sep 09 2017 14:05 Hello. Could someone explain the differences between those two: function addNumbers(a,b) { return a + b; } function addNumbers(a,b) { var total = a + b; return total; } Ronique Ricketts @RoniqueRicketts Sep 09 2017 14:09 @serhiicss the first function just return the sum of a and b but the second function first save the sum of a and b in and variable then return thr variable Serhii Borovskyi @serhiicss Sep 09 2017 14:11 @RoniqueRicketts Yes, but what is the advantage of using a var within a function in the example above? Ronique Ricketts @RoniqueRicketts Sep 09 2017 14:17 @serhiicss well its for scope. Let's say you have a variable on the global scope called total and you wanted to change that value inside the function that var total = a + b is like a safety bubble within the function that you can change the total variable and it doesn't affect the global scope. Serhii Borovskyi @serhiicss Sep 09 2017 14:20 @RoniqueRicketts Interesting! Thanks! CamperBot @camperbot Sep 09 2017 14:20 serhiicss sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles: :cookie: 388 | @roniquericketts |http://www.freecodecamp.com/roniquericketts Ronique Ricketts @RoniqueRicketts Sep 09 2017 14:21 Your welcome Serhii Borovskyi @serhiicss Sep 09 2017 14:22 One more question: If I run this code I get undefined for console.log. Why is that? function addN(a,b) { var total = a + b; console.log(total) } var total1 = addN(2,2); console.log(total1); Ronique Ricketts @RoniqueRicketts Sep 09 2017 14:23 total1 is not defined. Serhii Borovskyi @serhiicss Sep 09 2017 14:24 But isn't it what addN function returns? Ronique Ricketts @RoniqueRicketts Sep 09 2017 14:24 There is no return in the addN function look at it by adding return total after console.log (total) you should get a value Diego Mayer @Chrono79 Sep 09 2017 14:26 the function should return instead of console.log, if no explicit return is written the function returns undefined Serhii Borovskyi @serhiicss Sep 09 2017 14:28 Then why if I run the same code (without console.log), the console returns 4? function addN(a,b) { var total = a + b; console.log(total) } var total1 = addN(2,2); Fernando @lestairon Sep 09 2017 14:29 @Chrono79 It returns that... I tried with data.content, data[content] I really need to learn more Javascript lol Pieter Stokkink @forkerino Sep 09 2017 14:34 :wave: alpox @alpox Sep 09 2017 14:45 @serhiicss The function addN doesn't have any return value and total1 will be undefined. The console just shows the console.log output in addN - which is not the return value. To actually return something you have to use a return statement. Serhii Borovskyi @serhiicss Sep 09 2017 14:46 @alpox Thanks! CamperBot @camperbot Sep 09 2017 14:46 serhiicss sends brownie points to @alpox :sparkles: :thumbsup: :sparkles: :star2: 1329 | @alpox |http://www.freecodecamp.com/alpox WAINGOR @WAINGOR Sep 09 2017 14:48 hi all, I am at sum All fibonacci numbers (intermediat algo challenges) and somehow my code seems to cause an infinite loop.. does anyone know why?  function sumFibs(num) { var viboArray= [1,1,2]; var secondLast = viboArray[viboArray.length-2]; var last = viboArray[viboArray.length-1]; while(viboArray[viboArray.length-1]<=num ) { viboArray.push(viboArray[secondLast]+viboArray[last] ); } var sumAll = 1; for (var i=0; i<viboArray.length; i++) { if (!viboArray[i]%2) { sumAll += viboArray[i]; } } return sumAll; } sumFibs(4); Pieter Stokkink @forkerino Sep 09 2017 14:51 @WAINGOR when you push to viboArray, what do you push? WAINGOR @WAINGOR Sep 09 2017 14:52 00ps thnx Pieter Stokkink @forkerino Sep 09 2017 14:52 :+1: Moisés Man @moigithub Sep 09 2017 14:53 also sum should NOT start on 1 Marc @MWBauer Sep 09 2017 15:42 Hello everyone! HOw's the you? Pieter Stokkink @forkerino Sep 09 2017 15:53 Hey Marc @MWBauer :wave: Kelechi Chinaka @ke1echi Sep 09 2017 15:54 function remove(s){ let ex = ''; s = s.split(''); for (let i = 0; i < s.length; i++) { if (s[i] === '!') ex+=s.splice(i,1); } return s } remove("Hi! Hi!! Hi!") my code fails this test, i dunno know why its leaving the ! at index 5 Johnny @JohnnyBizzel Sep 09 2017 15:57 @kelechy Perhaps because you are modifying s inside the loop Kelechi Chinaka @ke1echi Sep 09 2017 16:00 i dnt understand, can u visualize with python tutor and see @JohnnyBizzel Pieter Stokkink @forkerino Sep 09 2017 16:03 @kelechy why do you even have an ex variable? The reason it goes wrong is what @JohnnyBizzel pointed out. Because if you splice, all letters to the right move over. But i will still increase by one. So you skip a character you haven't checked yet. Johnny @JohnnyBizzel Sep 09 2017 16:06 @forkerino :+1: thanks for explaining Kelechi Chinaka @ke1echi Sep 09 2017 16:09 ohkk s.splice(i,1,'') that fixed it oh i understand now thanks @JohnnyBizzel @forkerino CamperBot @camperbot Sep 09 2017 16:10 kelechy sends brownie points to @johnnybizzel and @forkerino :sparkles: :thumbsup: :sparkles: :star2: 2928 | @forkerino |http://www.freecodecamp.com/forkerino :star2: 1751 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel Johnny @JohnnyBizzel Sep 09 2017 16:11 @kelechy :+1: Ahmed raza @Raza403 Sep 09 2017 17:16 I am having strange error in "smallest common multiple" challenge, it works well for all except (23,18) input. For this it gives output 2018940, which is exactly 1/3 of the answer. Here is the code https://pastebin.com/V8a0D0Zq When I change quote in the code to 2018940 I get output 4037880 which is exact double of 2018940. And when I give 4037880 then return is 6056820 which is right answer. yofri @yofriadi Sep 09 2017 17:33 help me optimize my code here pls var increment = 0; var decrement = 21; for (var i=0; i<40; i++) { if (increment < 20) { increment++; console.log(${increment} - I love coding);
} else {
if (decrement === 1) {
break;
} else {
decrement--;
console.log(${decrement} - I will become a fullstack developer); } } } Moisés Man @moigithub Sep 09 2017 17:37 if u use 2 separated loops.. no extra variables or if conditions needed piteto @piteto Sep 09 2017 17:39 define "optimize" :) this is shorter var increment = 0; var decrement = 21; for (var i=0; i<40; i++) { if (increment++ < 20) console.log(${increment} - I love coding);
else if (decrement-- === 0) break;
else console.log(${decrement} - I will become a fullstack developer); } but not necessarily "optimized" for example, for reusability yofri @yofriadi Sep 09 2017 17:42 basically i want it to decrement after i increment it, i thought my solution too bloated luccifer00 @luccifer00 Sep 09 2017 18:02 if(count%file[file.length-1] == 0); what is the meaning of the %symbol?? i was googling but i cant find anything yofri @yofriadi Sep 09 2017 18:02 modulus? luccifer00 @luccifer00 Sep 09 2017 18:12 @Yofri modulus i guess so, but i dont know if could be an other thing Stein-T Dale @Lofthur Sep 09 2017 18:29 Hi. I'm on the Recipe Box project. Im trying to set up a form to add recipies . The thing is I want to add ingredients into an array inside an object called recipe. But react would not update after the first render. I then shifted the local object to a local state instead and then it worked. Is there a way i can set it up so it works with a local object instead of a state in this component. Is it ok to have a state here, or should i add the state to the App component and run everything via props? Here is the code if someone would take a look. :)   export class AddRecipeForm extends React.Component { constructor(props) { super(props); this.state = { name: '', desc: '', ingr: ['Ketchup', 'Pesto'], ingrStr: '' } this.addIngredient = this.addIngredient.bind(this); } addIngredient(ingredient) { const ingrArr = this.state.ingr; ingrArr.push(ingredient); this.setState({ ingr: ingrArr }); } createRecipe(e) { e.preventDefault(); console.log('recipe created'); } render() { return( <form onSubmit={this.createRecipe}> <input type="text" placeholder="Name" /> <div> <input ref={(input) => this.state.ingrStr = input} type="text" placeholder="Ingredient" /> <button type="button" onClick={() => this.addIngredient(this.state.ingrStr.value)}>Add</button> </div> <ul> {this.state.ingr.map(item => <li>{item}</li>)} </ul> <textarea cols="30" rows="10" placeholder="Description"></textarea> <button type="submit">Add Recipe</button> </form> ); } } Caleb David @microworlds Sep 09 2017 20:38 Hello guys have a question. I am using this library express-fileupload and I don't want to save uploaded files to any folder on the server, but mongodb instead. I want the files to be persisted to the database. How can I do that please, all contributions welcomed. Adel @AdelMahjoub Sep 09 2017 20:41 @microworlds you can use type: Buffer with mongoose @microworlds take a look at GridFS Caleb David @microworlds Sep 09 2017 20:44 @AdelMahjoub Thanks for that, let me look that out CamperBot @camperbot Sep 09 2017 20:44 microworlds sends brownie points to @adelmahjoub :sparkles: :thumbsup: :sparkles: :cookie: 545 | @adelmahjoub |http://www.freecodecamp.com/adelmahjoub Adel @AdelMahjoub Sep 09 2017 20:44 @microworlds you can read on the request stream and store the buffer in a variable, then store it to mongodb Caleb David @microworlds Sep 09 2017 20:45 @AdelMahjoub Yes, that was helpful. Thumps up man Adel @AdelMahjoub Sep 09 2017 20:46 let data = ''; req.on('data', chunk => { data += chunk }) req.on('end', () => { // here you can store data as a buffer }) Caleb David @microworlds Sep 09 2017 20:51 Copy that man!!! Thanks once more Adel @AdelMahjoub Sep 09 2017 20:51 @microworlds don't forget to save the file extension and the mime/type too, so you can read that buffer when you retrieve it Caleb David @microworlds Sep 09 2017 20:53 Thanks man Daniel @DanJP2016 Sep 09 2017 20:53 class Ninja { constructor() { let _skillLevel = 0; Object.defineProperty(this, 'skillLevel', { get: () => { console.log('getting skilllevel...'); return _skillLevel; }, set: value => { console.log('setting skilllevel...'); _skillLevel = value; } }); } } is this the only way to set private variables in classes? Jenky W. Nolasco @jenkynolasco11 Sep 09 2017 20:55 class Ninja { constructor(args){ this._privVar1 = 1 this._privVar2 = [...args] } _privVar3 = "string" } @DanJP2016 Oh wait... I misread the question Daniel @DanJP2016 Sep 09 2017 21:02 @jenkynolasco11 thank you. working my way through a book and been stuck on this for a few days now. CamperBot @camperbot Sep 09 2017 21:02 danjp2016 sends brownie points to @jenkynolasco11 :sparkles: :thumbsup: :sparkles: :star2: 1257 | @jenkynolasco11 |http://www.freecodecamp.com/jenkynolasco11 luccifer00 @luccifer00 Sep 09 2017 21:52 var input =$('#know').val();
var calc= Math.floor($(".boardPos").width()/input)+"px"; if(input>10){$(".tile").css({"width":calc,"heigth":calc});
}
hi guys!, i dont understand why the jquery is not working at this code...
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 21:53
.width()/input)+"px";
something missing there no?
looks strange
https://codepen.io/tiagocorreia/full/NvQaEz/ anyidea why I dont get 4 items per line?
luccifer00
@luccifer00
Sep 09 2017 21:54
even i change the calc for a write hand code "30px" the jquery is not working
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 21:55
try to console.log the input before the if
luccifer00
@luccifer00
Sep 09 2017 21:58
@tiagocorreiaalmeida the if is working find, becouse i créate a console.log inside the if, and it Works when the input box is a number ipper to 10
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 21:59
and if you console.log the cal
what you get
nm
JROD
@JROD1981
Sep 09 2017 22:04
Im working on Basic Algorithm Scripting "Falsy Bouncer". My code outputs the answer but it wont credit me but it returns "null" for the other answers.
function bouncer(arr1, arr2) {
var newArr = [];
var intersection = arr1.filter(function(e) {
if(arr2.indexOf(e) < 0){newArr.push(e);}
});
return newArr;
}

bouncer([7, "ate", "", false, 9], [false, null, 0, "", undefined, NaN]);
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:07
use array .filter
boolean values
function bouncer(arr) {
return arr.filter(Boolean);
}
luccifer00
@luccifer00
Sep 09 2017 22:08
@tiagocorreiaalmeida $("p").css({"background-color": "yellow", "font-size": "200%"}); this is the example on w3schools, and $(".tile").css({"width":calc,"heigth":calc}); is mine, where is the difference, i can not see it ( the calc returns a string like "20px" so i suppouse it is fine
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:08
do you have a pen for it?
luccifer00
@luccifer00
Sep 09 2017 22:13
yes
just write one number in the fild
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:17
seems to work?
I would recommend in the setting js
change jqueyr
to first and only then bootstrapjs
luccifer00
@luccifer00
Sep 09 2017 22:18
but when you want to créate a board upper to 10, the squares should reduce his size
i am trying to doing with out the if stat, and i can not change the css property
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:27
cause the element you are trying to target
doesnt exist on the doom when you call it
that's the problem I think
@luccifer00 got It I think
and you ?
luccifer00
@luccifer00
Sep 09 2017 22:29
that was the first thing i thougth, but i change the code, from one side to an other, and result the same....
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:30
nah
you have a for loop
after the count ++
the for closes
luccifer00
@luccifer00
Sep 09 2017 22:30
i am tryng with no if(), and also is not working...
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:30
$(document).ready(function(event){$("#action").click(function(event){

event.preventDefault();
var input = $('#know').val(); var calc= Math.floor($(".boardPos").width()/input)+"px";

$("#jumbcontain").css("background-color","silver");$("h1").css({"font-size":"15px", "text-align":"center"});

$("h1").text("You creates a "+ input +" x " +input+ " Dash"); var createBoard = function() { var rank1=[]; var file1=[]; for(var i=0;i<input;i++){ if(i==input-1){ file1+=i+1; rank1+=i+1; }else{ file1+= (i+1)+","; rank1+=(i+1)+","; } } var rank = rank1; var file = file1; var currentTile = {}; var count = 0; for(var i = 0; i < input; i++) { for (var j = 0; j < input; j++) { if(count%input === 0) {$("#chessboard").append('<div class="tile smoothfade" style="clear:left"></div>');

}else{
$("#chessboard").append('<div class="tile smoothfade"></div>'); }$(".tile").eq(count).attr("data-gridpos",((rank[rank.length - (i +1)]+file[j])));

if(((i%2 === 0) && (j%2 !== 0)) || ((i%2 !== 0) && (j%2 === 0)))
{
$(".tile").eq(count).addClass("black"); } else {$(".tile").eq(count).addClass("white");
}
count++;

}

}
if(input>10){
$(".tile").css({"width":calc,"heigth":calc}); } }; place this it will work but you will need to do this during the loop or only 1 will change luccifer00 @luccifer00 Sep 09 2017 22:31 i dont know if, to change the css, it is necesary to créate the elements, really... i will test with ur code.. Tiago Correia @tiagocorreiaalmeida Sep 09 2017 22:32 @luccifer00 $(document).ready(function(event){
$("#action").click(function(event){ event.preventDefault(); var input =$('#know').val();
var calc= Math.floor($(".boardPos").width()/input)+"px";$("#jumbcontain").css("background-color","silver");
("h1").css({"font-size":"15px", "text-align":"center"});("h1").text("You creates a "+ input +" x " +input+ " Dash");
var createBoard = function()
{
var rank1=[];
var file1=[];

for(var i=0;i<input;i++){

if(i==input-1){
file1+=i+1;
rank1+=i+1;
}else{
file1+= (i+1)+",";
rank1+=(i+1)+",";

}

}

var rank = rank1;
var file = file1;

var currentTile = {};

var count = 0;

for(var i = 0; i < input; i++)
{
for (var j = 0; j < input; j++)
{
if(count%input === 0)
{
$("#chessboard").append('<div class="tile smoothfade" style="clear:left"></div>'); }else{$("#chessboard").append('<div class="tile smoothfade"></div>');
}
$(".tile").eq(count).attr("data-gridpos",((rank[rank.length - (i +1)]+file[j]))); if(((i%2 === 0) && (j%2 !== 0)) || ((i%2 !== 0) && (j%2 === 0))) {$(".tile").eq(count).addClass("black");
}
else
{
$(".tile").eq(count).addClass("white"); } count++; } if(input>10){$(".tile").css({"width":calc,"heigth":calc});
}
}

};

document.getElementById("chessboard").innerHTML ="";
$("#panel").append(createBoard); });// end click console.log($(".boardPos").width());
});// end .ready
copy and past this will work
only 1 thing missing the height seems to not be setting u
up
luccifer00
@luccifer00
Sep 09 2017 22:38
yep the width now is change, but not the hewigth,, @tiagocorreiaalmeida thanks for all!, i can try by my own!!
CamperBot
@camperbot
Sep 09 2017 22:38
luccifer00 sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
Tiago Correia
@tiagocorreiaalmeida
Sep 09 2017 22:41
@luccifer00 if you dont get it working let me know
luccifer00
@luccifer00
Sep 09 2017 22:57
thanks! i found the error look at height`we wrote with an gth ending
John Otu
@johnotu
Sep 09 2017 23:39
Hi, Please let me know how I can improve my Wikipedia Viewer. I used React and Bootstrap.
https://codepen.io/johnotu/full/MmGVQB/