Hello,
I’m working through this front end project. How do I create / write the tweet function using plain javascript? I’ve written an array of quotes, instead of using an api.
Thank you.
Hello,
I’m working through this front end project. How do I create / write the tweet function using plain javascript? I’ve written an array of quotes, instead of using an api.
Thank you.
What have you tried so far?
const quotes = [
{
quote: "When people show you who they are believe them the first time",
author: "Maya Angelou"
},
{
quote: "A woman unaffected by insults has made her enemies absolutely powerless",
author: "Entity"
},
{
quote: "Life is the flower for which love is the honey.",
author: "Victor Hugo"
},
{
quote: "Love’s greatest gift is its ability to make everything it touches, sacred",
author: "Barbara De Angelis"
},
{
quote: "Be yourself as everyone else is taken",
author: "Oscar Wilde"
},
{
quote: "Your practice of forgiveness is your ticket to clarity, vitality and freedom.",
author: "Iyanla Vanzant"
},
{
quote: "Change the world by being yourself",
author: "Amy Poehler"
},
{
quote: "Every moment is a fresh beginning",
author: "T.S. Eliot"
},
{
quote: "Simplicity is the ultimate sophistication",
author: "Leonardo De Vinci"
},
{
quote: "What we think we become",
author: "Buddha"
}
];
const getRandomInt = function(max) {
return Math.ceil(Math.random() * Math.ceil(max));
}
const Text = props => {
return <div id="text">{props.text}</div>;
};
const Author = props => {
return <span id="author">{props.text}</span>
};
const Tweet = props => {
return (
<a
id="tweet-quote"
className="button"
href={"https://www.twitter.com/intent/tweet'';
.concat(props.tweet)}
target="_blank"
>
<i className="fab fa-twitter "/>
</a>
);
};
The part inside the {
and }
should concatenate the url and the props.tweet. You are not doing that at this point.
Thanks Randell. I took the quotes from different sites. Do I have to include all of the urls? Or will one suffice?
I don’t understand your question. There will only be a single url you will create using the base twitter url concatenated with props.tweet
.
Oh, sorry, my mistake.