- 2

Please how can help me solve this?

You are making a currency converter app. Create a function called convert, which takes two parameters: the amount to convert, and the rate, and returns the resulting amount. The code to take the parameters as input and call the function is already present in the Playground. Create the function to make the code work. Sample Input: 100 1.1 Sample Output: 110

2nd Mar 2022, 11:41 AM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
6 Answers
+ 1
Thanks too and what about this? You are working on a Contact Manager app. You have created the contact object constructor, which has two arguments, name and number. You need to add a print() method to the object, which will output the contact data to the console in the following format: name: number The given code declares two objects and calls their print() methods. Complete the code by defining the print() method for the objects.
2nd Mar 2022, 12:14 PM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
+ 4
If you dont understand lot of this get back and read again lections. Goal of every practice is checking knowledge, sometimes you didnt learn something and is fine to get back and learn again. When you can solve something by yourself then you learned this. In sololearn every practice is about lections we learned beffore. It is much better to post your attempt here then ask for solution, because we can tell you where you make mistake, so you dont repeat it. By copy/paste solution you wont learn. I tried to explain how my code works.
2nd Mar 2022, 12:26 PM
PanicS
PanicS - avatar
+ 4
Jamilu Abubakar Sadiq Contact Manager...remember from the lesson that a method is a function contained in the object. To print something to the console you use console.log and to access the properties of the object use 'this' . Lastly to bring your text and object properties together in the console.log concatenate with +. "something " + this property Name...
2nd Mar 2022, 12:38 PM
Paul K Sadler
Paul K Sadler - avatar
+ 3
Thanks too
2nd Mar 2022, 12:30 PM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
+ 2
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } // create convert function what take amount and rate as parameters and return output function convert (amount, rate) { // by data from question it look like you only need to multiply amount and rate 100 * 1.1 = 110 return amount * rate; } Edit: how it works? main function inside console log call convert function, made by you. This take 2 parameters amount and rate, this value we get from input. Then in convert function we return value of amount * rate, and this value is loged to console.
2nd Mar 2022, 11:55 AM
PanicS
PanicS - avatar
+ 2
In this your goal is to add print method what will log format name : number function contact(name, number) { this.name = name; this.number = number; // to add method you assign function, it is similar as normal value we need to use this keyword this.print = function () { // match format name : number // where name and number are value passed as parameters console.log(this.name + ": " + this.number); } } var a = new contact("David", 12345); var b = new contact("Amy", 987654321) a.print(); b.print();
2nd Mar 2022, 12:21 PM
PanicS
PanicS - avatar