The script above was the solution I provided for the question, but it's not working for some unknown reason. Is there an

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

The script above was the solution I provided for the question, but it's not working for some unknown reason. Is there an

Post by answerhappygod »

The Script Above Was The Solution I Provided For The Question But It S Not Working For Some Unknown Reason Is There An 1
The Script Above Was The Solution I Provided For The Question But It S Not Working For Some Unknown Reason Is There An 1 (110.06 KiB) Viewed 44 times
The script above was the solution I provided for the
question, but it's not working for some unknown reason. Is there
anything I'm doing wrong?
In a previous exercise, you were asked to create a car radio. The assignment required you to draw and label the components. In this lab you will build a simplified car radio object using the JavaScript template with several properties and methods. Your car radio object must meet the following requirements: 1. The car radio must be named carRadio. 2. The car radio must have the following components (properties): 1. power status - determines if the radio is off or on. 2. volume - provides the level of amplification ("loudness") 3. band - toggles between AM and FM radio bands. 4. station - indicates the frequency of the currently selected band. 3. The car radio must have a set and get method for EVERY property (4 set methods and 4 get methods). 4. The set methods for the following properties must meet the following conditions: 1. Power status can only accept the values "off" or "on". 2. Volume can only accept the values between 0 and 10 (inclusive). 3. Band only accept the values "AM" or "FM" (case sensitive). 4. Station doe not hay a condition, but in a more robust application we would need to set the range for the AM and FM band. Hint: Remember conditional statements are if statements or switch statements. By adding conditional statements we can ensure that our conditions are met. If an incorrect value is sent to the set method, the object should retain its previous value.
4 5 6 7 <body> <script> "use strict"; 8 let carRadio=1 NOCOJoin powerStatus:'off', volume: 0, 9 10 11 12 13 14 15 16 17 band: 'AM', station: 0, 18 get getPowerStatus() { return this.powerStatus}, set set PowerStatus (status) { if (status=='off' || status=='on') 19 20 21 22 23 24 25 26 27 28 29 this.powerStatus=status } get getVolume() { return this.volume }, 30 set setVolume (volume) { if(volume>=0 && volume<=10) this.volume=volume } 31 32 33 34 35 36 37 38 39 40 41 42 43 get getBand () { return this.band), set setBand (band) { if (band=='AM' || band='FM) this.band=band - }, 45 46 47 48 49 50 get getStation() { return this.station), set setStation (station) { 51 52 this.station=station 53 54 } 55 56 } F</script> 57
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply