Remember, MainUI Widgets and Rules are written in completely different languages (usually) and operating in completely different environments. MainUI Widgets are JavaScript running in your browser. Rules may be JavaScript, among other language choices, but they are running on your OH server. Furthermore, most of the stuff the Rules interact with are Java Objects and Java doesn’t even exist on the UI.
So there should be no expectation that you can take a line of code from a rule and have it work in the UI unfortunately.
JavaScript doesn’t have an as operation. Number in your rule is referring to the Java Number which doesn’t even exist in the UI. JavaScript does have a Number class but it’s used to parse stuff and doesn’t hold a value itself so it doesn’t have an intValue. Unlike in Rules DSL, when calling a function that doesn’t have arguments, the ( ) is required so if intValue did exists, you’d have to call it using .intValue().
What you do have in the UI widget:
items[wBedRoom_Day_Num].state is a string representation of the state of the Item, it’s not a number and it might have extra stuff like units of measurement