Create a function formatWeatherReport which takes 3 parameters : cityName, tempC and showFahrenheit

who can help me solve this code pls. Create a function formatWeatherReport which takes 3 parameters : cityName, tempC and showFahrenheit and returns the weather report string like this: ```
In Vancouver it is currently :cold_face: 37.4°F
In New Delhi it is currently :hot_face: 35°C
In Sydney it is currently :blush: 17°C
In Miami it is currently :hot_face: 104°F

console.log(result);// "In Vancouver it is currently 🥶 42.8°F"

hi there,

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

1 Like

Thank you, will put in effort atleast 4-5 hours per day on FCC curriculum

Here is what i have been working on but i feel stuck somewhere. it says i should use the previous functions i created which was formatTemperatureAsString and convertToEmojiFace to write a function formatWeatherReport

can you share the code in a pastebin or copy the actual code here? (pictures of code are hard to read)

function convertToFahrenheit(tempc){
  return tempc * 9/5 + 32;

function formatTemperatureAsString(tempc, convertToF){
    if (convertToF === true){
        return convertToFahrenheit(tempc) + "°F";
    else {
        return tempc + "°C";
function convertToEmojiFace(tempc){
    if (tempc > 30){
        return "🥵";
    else if (tempc > 12){
        return "😊";
    else {
        return "🥶";
function formatWeatherReport(cityName, tempc, showFahrenheit){
    if (showFahrenheit === false){
        return convertToEmojiFace + formatTemperatureAsString;
    else if(tempc > 6){
        return tempc;
        return "In" + cityName + "it is currently" + tempc * 9/5 + 32;  
let result = formatWeatherReport('Vancouver', 6, true);
console.log(result);// "In Vancouver it is currently 🥶 42.8°F"

look at your code again. Do you see the redundancy?
You have in multiple places the formula for calculating Fahrenheit.

also it looks like you are not calling the functions properly (you need to pass some arguments to the functions as needed)

Edit: also why are you treating temp > 6 in a special way?
For all temps you should have been using the same code.

okay thanks for the tips, let work it out again

1 Like

thanks for the response, i was thinking since tempc is 6, i will result to 10.832 + 32 which should print 42.832

This is how the code should be. i’m supposed to get weatherreport using the previous two functions but i am lost. been trying to code this for more than an hour

okay thank you, taken note of that

Just try to look at what you have already.

1- you have a function convertToFahrenheit which takes a temp in C and returns the Fahrenheit value, correct? So whenever you need to change C to F, use it.

2- you have a function formatTemperatureAsString which takes a temp in C and 2nd param to decide if it should be shown in C or F and then it produces something formatted for printing made up of the temp and the units. So use this whenever you need to print the temp with its units

3- you have a function convertToEmojiFace which take a temp in C and produces an emoji. So use that when you need an emoji

Combine these three to produce the formatted result you’ve been asked to provide.

i will really put in time on the FCC curriculum atleast 4 hours a day to see how things goes for me . i desperately want to master javascript

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.