get help in general - we have more specialized help rooms here: https://gitter.im/FreeCodeCamp/home
123
java problem?
isNaN
(and if it is, it should discard it from the array)
sort
and then filter
or in one go using a reducer
function
self.restaurant.operating_hours
isn't set?
@-webkit-keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-moz-keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-o-keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
.fadeIn {
opacity: 0;
animation-name: fadeIn;
animation-duration: 2s;
animation-fill-mode: forwards;
}
render(){
return(
<div id="quote-box" className="container-fluid row">
<div className="fadeIn" id="text">
<p>{this.state.quote}</p>
</div>
<div className="fadeIn" id="author">
<p>{this.state.author}</p>
</div>
<div className="buttons">
<button className="button" onClick={this.getQuote} id="new-quote">New Quote!</button> <br />
<a className="button" title="Tweet!" className="fa fa-twitter fa-lg" href="#" onClick={this.tweetQuote} id="tweet-quote"></a>
</div>
</div>
);
};
};
darrenfj sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3776 | @khaduch |http://www.freecodecamp.org/khaduch
ingredients
variable is all undefined
console.log(ingredients)
import React from 'react';
import {Pie} from 'react-chartjs-2';
class ShowForm extends React.Component {
constructor (props) {
super(props)
this.state = {
votingOption: 0,
addOptions: ""
};
}
submitVote = (e) => {
e.preventDefault();
const url = `${this.props.url}${this.props.pollId}`;
fetch(url, {
method: 'POST',
body: JSON.stringify({'voteOn' : this.state.votingOption }),
headers: new Headers({
'Content-Type': 'application/json'
})
}).then(res => alert("Thanks for voting!"))
.catch(error => console.error('Error:', error));
}
deletePoll = (e) => {
e.preventDefault();
const url = `${this.props.url}${this.props.pollId}`;
fetch(url, {
method: 'DELETE',
body: JSON.stringify({}),
headers: new Headers({
'Content-Type': 'application/json'
})
}).then(res => alert("Poll deleted!"))
.catch(error => console.error('Error:', error));
}
addOptions = (e) => {
e.preventDefault();
const url = `${this.props.url}${this.props.pollId}`;
const optionsArr = JSON.parse(JSON.stringify(this.props.pollOptions));
optionsArr.push(this.state.addOptions);
this.setState({addOptions: ""})
fetch(url, {
method: 'PUT',
body: JSON.stringify({"options" : optionsArr}),
headers: new Headers({
'Content-Type': 'application/json'
})
}).then(res => alert("Option Added!"))
.catch(error => console.error('Error:', error));
}
render() {
const colors = ['#FF6384', '#36A2EB', '#FFCE56', '#F19CBB', '#D1001C', '#7F3E98', '#4682BF', '#D2691E']
const data = {
labels: this.props.pollOptions.map(d => d),
datasets: [
{
data: this.props.pollVotes,
backgroundColor: colors,
hoverBackgroundColor: colors
}
]
};
return (<div className="panel panel-default">
<div className="panel-heading">
{this.props.pollName}
<button type="button" className="close" onClick={this.deletePoll}>
<span aria-hidden="true">Delete</span>
</button>
</div>
<div className="panel-body">
<form>
<div className="row form-group">
<div className="col-sm-5">
<label>Select Option</label>
<select className="form-control" onChange={e => this.setState({ votingOption: e.target.value })}>
{this.props.pollOptions.map((option, i) => <option key={option} value={i}>{option}</option>)}
</select>
<br/>
<button onClick={this.submitVote} className='btn btn-block btn-primary center-block'>Vote</button>
<div style={{display:'flex'}}>
<input style={{marginTop:'15px'}} onChange={e => this.setState({ addOptions: e.target.value })} placeholder='Add another option' className='form-control'/> <br />
<button style={{margin:'15px'}} className="btn btn-primary" onClick={this.addOptions}>Add</button>
</div>
</div>
<div className="col-sm-5">
<Pie data={data} width={20} height={5} /*options={{maintainAspectRatio: false}}*//>
</div>
</div>
</form>
</div>
</div>)
}
}
export default ShowForm;
nreviews
that doesn't seem to be defined - and it is used in a few places?
var nreviews = [];
it starts to work - it will at least display the labels with names values of "undefined"... but it adds a new entry after Add button.
dkapexhiu sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3777 | @khaduch |http://www.freecodecamp.org/khaduch
this
in your function describe
is not working. I think that if you pass the review that you are processing into the function, and use that parameter to access the various review properties, you can get the data. The data seems to be getting stored into the nreviews
array, just not being pulled out.
@dkapexhiu - the basic idea would be in the place where you are trying to display the data, within the showData()
function - do something like this:
function showData() {
debugger;
var tmp = "<ul>";
nreviews.forEach(function(review) {
tmp += "<li>" + reviews.describe(review) + "</li>";
});
_("reviews").innerHTML = tmp + "</ul>";
}
Just passing the current review
variable to your describe
method. And change the describe
method to look like this:
describe: function(rev) {
var description =
"Name:" +
rev.name +
"<br>" +
"Date:" +
rev.date +
"<br>" +
"Comment:" +
rev.comment;
return description;
}
using a function argument rev
(or a name of your choice) and then using that to access the variable properties of your description. It's really rough-looking, some output styling should be done, but it gets the information onto the screen...
dkapexhiu sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: